【问题标题】:pagination issue with new wordpress template新的 wordpress 模板的分页问题
【发布时间】:2016-04-25 11:53:53
【问题描述】:

网站博客here

尽管地址栏中出现了相应的第 2 页 URL,但当按下第 2 页时,博客页面底部的分页不会将内容更改为第 2 页帖子 - 此外,地址栏时第 2 页按钮不会显示为选中状态显示第 2 页 -

我用过this theme before on this website 安装时也存在分页问题,​​但由现在无法联系的创建者排序-

似乎这个主题的每次全新安装都有分页问题,​​直到编辑某些内容 -

只是补充一点,我不确定要发布哪些代码 sn-ps,所以如果有帮助,请告诉我哪些文件,但如果这是正确的代码,这里是来自 template-blog 的 sn-p。 php

<?php
if(is_category() || is_archive()){
    /*get page with blog template set*/
    $post_template_page_array = get_pages(array(
        'post_type' => 'page',
        'post_status' => 'publish',
        'number' => 1,
        'meta_key' => '_wp_page_template',
        'meta_value' => 'template-blog.php',
        'sort_order' => 'ASC',
        'sort_column' => 'menu_order',
    ));
    $post_template_page = $post_template_page_array[0];

    echo wpb_js_remove_wpautop(apply_filters('the_content', $post_template_page->post_content));
    global $post;
    $post = $post_template_page;
    setup_postdata($post);
} else {
    if(have_posts()) : while (have_posts()) : the_post();
        the_content();
    endwhile; endif;
}
?>

非常感谢任何可以为此提出解决方案的人:)

【问题讨论】:

  • 尝试刷新您的重写规则 - 转到永久链接设置并保存它们。

标签: php wordpress pagination


【解决方案1】:

wordpress 中的分页:

示例分页代码:

<?php if ( have_posts() ) : ?>

<!-- Add the pagination functions here. -->

<!-- Start of the main loop. -->
<?php while ( have_posts() ) : the_post();  ?>

 <!-- the rest of your theme's main loop -->

 <?php endwhile; ?>
 <!-- End of the main loop -->

 <!-- Add the pagination functions here. -->

  <div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
 <div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>

<?php else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>

更多参考:URL

【讨论】:

    猜你喜欢
    • 2011-11-18
    • 1970-01-01
    • 2014-09-06
    • 2012-10-08
    • 1970-01-01
    • 2021-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多