【问题标题】:Can some one explain why WordPress pagination doesn't like custom loops?有人可以解释为什么 WordPress 分页不喜欢自定义循环吗?
【发布时间】:2013-01-12 15:52:59
【问题描述】:

我的问题与This other stack post 完全相同。我怎么无法弄清楚回复者的意思。我已经在我的自定义循环中尝试了他们的示例,它看起来与 OP 相同,但是分页不起作用。它不显示。

我在这个循环中也有这个问题:

$attr = array(
    'align' => 'left',
    'class' => 'thumbnail imageRight',
    'width' => 350,
    'height' => 350
);

if(have_posts()){
    while(have_posts()){
        the_post();
        ?>
        <div class="post">
            <?php the_post_thumbnail('medium', $attr); ?>
            <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
            <p><?php the_excerpt(); ?></p>
        </div>
        <?php
    }

    next_posts_link('&laquo; Older Entries');
    previous_posts_link('Newer Entries &raquo;');
}

分页根本不会显示,如果我在上方和下方回显某些内容,我会看到回显的文本 obv,但我看不到分页链接....

我已将 WP 设置为每页显示 3 个帖子,并且我在数据库中有超过 45 个帖子。

【问题讨论】:

标签: php wordpress pagination wordpress-theming


【解决方案1】:

我一遍又一遍地遇到这个问题 - 我不知道您是否使用自定义页面模板,但最后我只是使用存档页面而不是查询类别或帖子类型 - 例如 archive-portfolio.php 和分页只是在这上面工作。 - 其中一些问题会引起数小时的刺激,但这似乎可以解决问题。

【讨论】:

    猜你喜欢
    • 2012-01-26
    • 2020-08-16
    • 2019-09-14
    • 1970-01-01
    • 2016-04-18
    • 2015-10-16
    • 2019-09-11
    • 2016-06-01
    • 1970-01-01
    相关资源
    最近更新 更多