首页 > 解决方案 > 我能做些什么?当 Wordpress 列出阅读次数最多时,我无法分页

问题描述

当 Wordpress 列出阅读次数最多时,我无法分页。

我使用的代码:functions.php

<?php
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 okunma";
}
return $count.' okunma';
}
function setPostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
?>

我使用的代码:single.php

<?php setPostViews(get_the_ID()); ?><?php echo getPostViews(get_the_ID()); ?>

我使用帖子列表的代码:

<?php
    query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC&posts_per_page=10');
    if (have_posts()) : while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php
    endwhile; endif;
    wp_reset_query();

?>

分页在最大 10 时不起作用,即使我减少了数字。

我在自定义页面模板中使用列表代码。

但是分页功能不起作用。

有没有人对此有不同的建议?

它以不同的编码发生。我不想要任何插件。

对不起,如果我的英语犯了一个严重的错误。谢谢您的帮助。

标签: wordpress

解决方案


推荐阅读