wordpress - 我能做些什么?当 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 时不起作用,即使我减少了数字。
我在自定义页面模板中使用列表代码。
但是分页功能不起作用。
有没有人对此有不同的建议?
它以不同的编码发生。我不想要任何插件。
对不起,如果我的英语犯了一个严重的错误。谢谢您的帮助。
解决方案
推荐阅读
- python - 接口类型的内存视图与 python slice 对象
- amazon-web-services - 为联合身份 AWS 创建长期凭证
- javascript - JS 正则表达式字符串不会以句点/点结尾
- python - Python对象相等比较
- java - 从数据库中提取值进行操作并将它们保存在另一个表中 android
- r - 如何使用逆 CDF 方法从逻辑 CDF 生成样本
- jpa - JPA 问题:持久化具有 EmbeddedId 复合键的关联类时遇到问题
- javascript - 为什么一段代码会覆盖另一段代码?
- python - Sqlite中的变量使用python
- git - 强制 Git 总是覆盖某些文件