本文整理汇总了PHP中get_post_custom_values函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_custom_values函数的具体用法?PHP get_post_custom_values怎么用?PHP get_post_custom_values使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_custom_values函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: property_post_list
function property_post_list()
{
$propid_array = array();
$args = array('numberposts' => -1, 'meta_key' => 'property_id');
$posts_array = get_posts($args);
if (count($posts_array) > 0) {
foreach ($posts_array as $p) {
//print_r($posts_array);exit();
$propid = get_post_custom_values('property_id', $p->ID);
if (!empty($propid)) {
$prop_array[$p->ID] = $propid;
}
}
}
?>
<script>
var prop_post_array = new Array();
<?php
foreach ($prop_array as $po => $pr) {
?>
prop_post_array[<?php
echo $pr[0];
?>
] = <?php
echo $po;
?>
;
<?php
}
?>
</script>
<?php
}
示例2: ktz_jsscripts
function ktz_jsscripts()
{
global $is_IE, $post;
if (!is_admin()) {
if (is_object($post)) {
$ktz_self_video_youtube_mt = get_post_custom_values('ktz_youtube_id', $post->ID);
$ktz_self_video_vimeo_mt = get_post_custom_values('ktz_vimeo_id', $post->ID);
$ktz_self_video_dailymotion_mt = get_post_custom_values('ktz_dailymotion_url', $post->ID);
global $post;
$meta_values = get_post_custom($post->ID);
}
if (is_singular()) {
wp_enqueue_script('comment-reply');
}
wp_enqueue_script('modernizr-respon');
wp_enqueue_script('ktz-jsscript-js');
wp_enqueue_script('ktz-rating-js');
if (is_single() && has_post_format('video')) {
wp_enqueue_script('ktz-video-js');
}
if (is_single() && $ktz_self_video_youtube_mt && has_post_format('video')) {
wp_enqueue_script('ktz-video-youtube-js');
}
if (is_single() && $ktz_self_video_vimeo_mt && has_post_format('video')) {
wp_enqueue_script('ktz-video-vimeo-js');
}
if (is_single() && $ktz_self_video_dailymotion_mt && has_post_format('video')) {
wp_enqueue_script('ktz-video-dailymotion-js');
}
wp_enqueue_script('ktz-main-js');
wp_localize_script('ktz-rating-js', 'ktz_ajax_data', array('ajax_url' => admin_url('admin-ajax.php'), 'codes' => array('SUCCESS' => 1, 'PREVIOUSLY_VOTED' => 0, 'REQUEST_ERROR' => 2, 'UNKNOWN' => -1), 'messages' => array('success' => __('You\'ve voted correctly', ktz_theme_textdomain), 'previously_voted' => __('You had previously voted', ktz_theme_textdomain), 'request_error' => __('The request was malformed, try again', ktz_theme_textdomain), 'unknown' => __('An unknown error has occurred, try to vote again', ktz_theme_textdomain))));
}
}
示例3: wp_ozh_yourls_newpost
function wp_ozh_yourls_newpost($post)
{
global $wp_ozh_yourls;
$post_id = $post->ID;
$url = get_permalink($post_id);
if ($post->post_type != 'post' && $post->post_type != 'page') {
return;
}
// Generate short URL ?
if (!wp_ozh_yourls_generate_on($post->post_type)) {
return;
}
$title = get_the_title($post_id);
$url = get_permalink($post_id);
$short = wp_ozh_yourls_get_new_short_url($url);
// Tweet short URL ?
if (!wp_ozh_yourls_tweet_on($post->post_type)) {
return;
}
if (!get_post_custom_values('yourls_tweeted', $post_id)) {
// Not tweeted yet
$tweet = wp_ozh_yourls_maketweet($short, $title);
if (wp_ozh_yourls_send_tweet($tweet)) {
update_post_meta($post_id, 'yourls_tweeted', 1);
}
}
}
示例4: post_thumbnail_src
function post_thumbnail_src()
{
global $post;
if ($values = get_post_custom_values("thumb")) {
//输出自定义域图片地址
$values = get_post_custom_values("thumb");
$post_thumbnail_src = $values[0];
} elseif (has_post_thumbnail()) {
//如果有特色缩略图,则输出缩略图地址
$thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
$post_thumbnail_src = $thumbnail_src[0];
} else {
$post_thumbnail_src = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$post_thumbnail_src = $matches[1][0];
//获取该图片 src
if (empty($post_thumbnail_src)) {
//如果日志中没有图片,则显示随机图片
$random = mt_rand(1, 10);
echo get_bloginfo('template_url');
echo '/images/random/' . $random . '.jpg';
//如果日志中没有图片,则显示默认图片
//echo '/images/default_thumb.jpg';
}
}
echo $post_thumbnail_src;
}
示例5: tumblrLinkBacks
function tumblrLinkBacks($content)
{
global $wp_query, $post;
$post_id = get_post($post->ID);
$posttitle = $post_id->post_title;
$permalink = get_permalink(get_post($post->ID));
$tumblr_keys = get_post_custom_keys($post->ID);
if (get_post_meta($wp_query->post->ID, 'TumblrURL', true)) {
if ($tumblr_keys) {
foreach ($tumblr_keys as $tumblr_key) {
if ($tumblr_key == 'TumblrURL') {
$tumblr_vals = get_post_custom_values($tumblr_key);
}
}
if ($tumblr_vals) {
if (is_feed()) {
$content .= '<p><a href="' . $tumblr_vals[0] . '" title="Direct link to featured article">Direct Link to Article</a> — ';
$content .= '<a href="' . $permalink . '">Permalink</a></p>';
return $content;
} else {
return $content;
}
}
}
} else {
$content = $content;
return $content;
}
}
示例6: AB_external_permalink
function AB_external_permalink($permalink)
{
global $post;
$thePostID = $post->ID;
$internal_post = get_post($thePostID);
$title = $internal_post->post_title;
$post_keys = array();
$post_val = array();
$post_keys = get_post_custom_keys($thePostID);
if (!empty($post_keys)) {
foreach ($post_keys as $pkey) {
if ($pkey == 'original_source') {
$post_val = get_post_custom_values($pkey, $thePostID);
break;
}
}
if (empty($post_val)) {
$link = $permalink;
} else {
$link = $post_val[0];
}
} else {
$link = $permalink;
}
return $link;
}
示例7: custom_actions
/**
* Adds the custom actions to the Commits list.
* @access public
* @param array $actions The default array of actions.
*/
public function custom_actions($actions)
{
if (get_post_type() == 'revisr_commits') {
if (isset($actions)) {
unset($actions['edit']);
unset($actions['view']);
unset($actions['trash']);
unset($actions['inline hide-if-no-js']);
$id = get_the_ID();
$url = get_admin_url() . 'post.php?post=' . get_the_ID() . '&action=edit';
$actions['view'] = "<a href='{$url}'>" . __('View', 'revisr') . "</a>";
$branch_meta = get_post_custom_values('branch', get_the_ID());
$db_hash_meta = get_post_custom_values('db_hash', get_the_ID());
$backup_method = get_post_custom_values('backup_method', get_the_ID());
$commit_hash = Revisr_Git::get_hash($id);
$revert_nonce = wp_nonce_url(admin_url("admin-post.php?action=process_revert&commit_hash={$commit_hash}&branch={$branch_meta[0]}&post_id=" . get_the_ID()), 'revert', 'revert_nonce');
$actions['revert'] = "<a href='" . $revert_nonce . "'>" . __('Revert Files', 'revisr') . "</a>";
if (is_array($db_hash_meta)) {
$db_hash = str_replace("'", "", $db_hash_meta);
if (isset($backup_method) && $backup_method[0] == 'tables') {
$revert_db_nonce = wp_nonce_url(admin_url("admin-post.php?action=revert_db&db_hash={$db_hash[0]}&branch={$branch_meta[0]}&backup_method=tables&post_id=" . get_the_ID()), 'revert_db', 'revert_db_nonce');
} else {
$revert_db_nonce = wp_nonce_url(admin_url("admin-post.php?action=revert_db&db_hash={$db_hash[0]}&branch={$branch_meta[0]}&post_id=" . get_the_ID()), 'revert_db', 'revert_db_nonce');
}
if ($db_hash[0] != '') {
$actions['revert_db'] = "<a href='" . $revert_db_nonce . "'>" . __('Revert Database', 'revisr') . "</a>";
}
}
}
}
return $actions;
}
示例8: get_post_thumb
function get_post_thumb($post_id, $width, $height, $custom = "image")
{
//universal thumb function
$show_no_image = get_option("bordeaux_show_first_thumb");
$custom_image = get_post_custom_values($custom, $post_id);
//get custom field value
$custom_image = $custom_image[0];
if ($custom_image == "" && $custom != "image") {
$custom = "bordeaux_slider_image";
$custom_image = get_post_custom_values($custom, $post_id);
//get custom field value
$custom_image = $custom_image[0];
}
$meta = get_post_meta($post_id, "_thumbnail_id", true);
//get wordpress built in thumbnail value
$first_from_post = get_first_image($post_id);
//get first image form post
if ($custom_image != "") {
//custom field value
$file = $custom_image;
if (strpos($file, "wp-content") !== false) {
$pos = strpos($file, "/wp-content");
$file = substr($file, $pos);
}
$src = get_template_directory_uri();
$src .= "/timthumb.php?src=";
$src .= $file;
$src .= "&w={$width}&h={$height}&zc=1&q=100";
$show_image = true;
} elseif ($meta) {
//built in thumb
$file = site_url() . "/wp-content/uploads/" . get_post_meta($meta, "_wp_attached_file", true);
$src = get_template_directory_uri();
$src .= "/timthumb.php?src=";
$src .= $file;
$src .= "&w={$width}&h={$height}&zc=1&q=100";
$show_image = true;
} elseif ($first_from_post != false && $custom != "bordeaux_slider_image") {
//first attached image
$file = $first_from_post;
if (strpos($file, "wp-content") !== false) {
$pos = strpos($file, "/wp-content");
$file = substr($file, $pos);
}
$src = get_template_directory_uri();
$src .= "/timthumb.php?src=";
$src .= $file;
$src .= "&w={$width}&h={$height}&zc=1&q=100";
$show_image = true;
} else {
//no image
$src = get_template_directory_uri() . '/images/no-image-' . $width . 'x' . $height . '.jpg';
if ($show_no_image == "on") {
$show_image = true;
} else {
$show_image = false;
}
}
return array("src" => $src, "show" => $show_image);
}
示例9: cs_external_permalink
function cs_external_permalink($permalink)
{
global $post;
$thePostID = $post->ID;
$post_id = get_post($thePostID);
$title = $post_id->post_title;
$post_keys = array();
$post_val = array();
$post_keys = get_post_custom_keys($thePostID);
if (!empty($post_keys)) {
foreach ($post_keys as $pkey) {
if ($pkey == 'url1' || $pkey == 'title_url' || $pkey == 'url_title' || $pkey == 'external') {
$post_val = get_post_custom_values($pkey);
}
}
if (empty($post_val)) {
$link = $permalink;
} else {
$link = $post_val[0];
}
} else {
$link = $permalink;
}
return $link;
}
示例10: format_custom_field
function format_custom_field($field, $format = '', $date_format = 'F j, Y')
{
$fetch = get_post_custom_values($field);
$fetch = $fetch[0];
// Test if anything was fetched or return false.
if (!$fetch) {
return false;
}
switch ($format) {
case 'date':
return date($date_format, $fetch);
break;
case 'text_block':
return wpautop($fetch);
break;
case 'link':
return '<a href="' . $fetch . '" class="custom_link">' . $fetch . '</a>';
break;
case 'html':
return html_entity_decode($fetch);
break;
case 'google_map':
return display_google_map($fetch);
break;
default:
// If you're not processing(formatting) the var at all
// why even use this function? Just use the WP custom field funcs.
return $fetch;
}
}
示例11: woo_get_page_template
/**
* Get the current page template
*
* Get the current page template in use.
*
* @since 4.0
*
* @package WooFramework
* @subpackage Template
*/
function woo_get_page_template()
{
global $wp_query;
$page = $wp_query->get_queried_object();
$custom_fields = get_post_custom_values('_wp_page_template', $page->ID);
$page_template = $custom_fields[0];
return $page_template;
}
示例12: cftpb_get_term_custom_values
function cftpb_get_term_custom_values($term_id, $taxonomy, $key)
{
$return_val = null;
$term_post = cf_taxonomy_post_type_binding::get_term_post($term_id, $taxonomy);
if (!empty($term_post) && !is_wp_error($term_post)) {
$return_val = get_post_custom_values($key, $term_post->ID);
}
return $return_val;
}
示例13: custom_field
function custom_field($field, $post_id)
{
$cf = get_post_custom_values($field, $post_id);
if (count($cf) > 1) {
return $cf;
} else {
return array_shift($cf);
}
}
示例14: ta_modified_post_title
function ta_modified_post_title($title)
{
if (in_the_loop() && !is_page()) {
$title_word_count = get_post_custom_values('wc_the_word_count');
if ($title_word_count) {
$title = $title . ' (Word Count: ' . $title_word_count[0] . ')';
}
}
return $title;
}
示例15: get_reservation_page
function get_reservation_page()
{
$pages = get_pages();
foreach ($pages as $p) {
$meta = get_post_custom_values("_wp_page_template", $p->ID);
if ($meta[0] == "template-reservations.php") {
return $p->ID;
}
}
return false;
}