是的,您必须计算页面浏览量。不要使用插件,因为它需要一小段代码
下面的代码将增加页面浏览量并存储在post meta中。在单个中使用此代码。php或循环公用。
if( is_single() ) {
/* Increase post view count by 1 */
$post_view_count = get_post_meta($post_id, \'view_count\', true);
if( $post_view_count==\'\' ) {
update_post_meta($post_id, \'view_count\', 1);
}
else{
$post_view_count = intval($post_view_count);
++$post_view_count;
update_post_meta($post_id, \'view_count\', $post_view_count);
}
}
Reteriving posts based on views
$popular_query = array( \'post_type\' => \'post\', \'posts_per_page\' => 5, \'order\' => \'DESC\', \'orderby\' => \'meta_value_num\', \'meta_key\' => \'view_count\');
UPDATE
像这样将代码粘贴到single中(按原样,post\\u id不变)。php。
function custom_categories_listing()
{
$categories = get_the_category($post->ID);
if(!empty($categories)){
foreach ($categories as $cat) {
$html = \'\';
$html .= \'cat_ID) . \'" class="odd"\';
$html .= \'title="\' . $cat->cat_name . \'">\' . $cat->cat_name . \'\';
echo $html;
}
}
}
/* Increase post view count by 1 */
$post_id = get_the_ID();
$post_view_count = get_post_meta($post_id, \'view_count\', true);
if( $post_view_count==\'\' ) {
update_post_meta($post_id, \'view_count\', 1);
}
else{
$post_view_count = intval($post_view_count);
++$post_view_count;
update_post_meta($post_id, \'view_count\', $post_view_count);
}
?>
下面是custom\\u categories\\u listing函数,上面是面包屑。
现在我想你可以弄明白了。