function get_post_meta($post_id, $key = '', $single = false) {
return get_metadata('post', $post_id, $key, $single);
}
<?php
$post_id = $post->ID;
$post_views = wp_cache_get($post_id,'views');
if($post_views === false){
$post_views = get_post_meta($post_id, "views",true);
if(!$post_views) $post_views = 0;
}
$post_views = $post_views + 1;
wp_cache_set($post_id,$post_views,'views');
if($post_views%10 == 0){
update_post_meta($post_id, 'views', $post_views);
}
echo $post_views;
?>
以上就是安达网络工作室关于《wordpress获取自定义字段get_post_meta函数使用介绍》的一些看法。更多内容请查看本栏目更多内容!
WordPress网站在改换域名后,需求从新配置以后域名能力使得网站失常运转,很多人遇到过这样的状况,那么如何...
前段工夫,WordPress 网站受到了大规模的暴力破解攻打,攻打者首先扫描互联网上的 WordPress 网站,而后利...
get_search_form 函数在 WordPress 中是用来提取预设的搜寻表单或许默许的搜寻表单的。由于民间这个函数没有...
缺点文件/{Path}/wp-includes/registration-functions.php 要害代码: —-> <?php /** * Deprecated. N...
1. 它能够进步用户体验, 调动访客回复的踊跃性, 从而添加评论的数量, 能让博客变得像社区一样活泼. 2. 博客...
最新版本的WordPress 2.8的公布,为WordPress网站开发者带来了更多的便当,让像WPYOU这样的基于WordPress的...