对于CPT的NEXT_POST_LINK只在几个帖子中工作?太奇怪了!

时间:2015-01-21 作者:Seb Szocinski

I have about 20-30 posts in a CPT, and when I click on a single post and use the next_post_link and prev_post_link functions it will only show a select 5 posts out of the 20-30... always the same 5 as well.. I can\'t for the life of me work out why!

I\'ve tried limiting to taxonomies or categories but that just brings it down to 0 links.

Has anyone come across this?

EDIT: I\'m using a very streamlined install... the only plugins are CPT UI for the Custom Post Type and ACF for the fields.

Here is my code for the single-books.php (Single CPT page) the url is site.com/books/book-name

<?php get_header(); ?>
<main role="main">
    <section>

    <?php if (have_posts()): while (have_posts()) : the_post(); ?>

        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

            <div class="col3">
                <h1 class="title"><span><?php the_title(); ?></span></h1>
            </div>
            <div class="col3">
                <div class="cover">
                    <?php $cover = wp_get_attachment_image_src( get_field(\'cover_image\'), \'book\' ); ?>
                    <img src="<?php echo $cover[0]; ?>" alt="">
                </div>
            </div>
            <div class="col3">

            </div>

            <div class="clear"></div>

            <div class="col3">
                <span class="label">Author:</span>
                <span class="data"><?php the_field(\'author\') ?></span>
                <span class="label">Publisher:</span>
                <span class="data"><?php the_field(\'publisher\') ?></span>
                <span class="share">[ Share ]</span>
            </div>

            <div class="col3">
                <span class="label">Review</span>
                <span class="data"><?php the_content(); ?></span>
            </div>

            <div class="col3">
                <span class="label">Publication Date:</span>
                <span class="data"><?php the_field(\'publication_date\') ?></span>
                <span class="label">Genre:</span>
                <span class="data"><?php echo get_the_term_list( $post->ID, \'genres\', \'\', \', \', \'\' ) ?></span>
                <span class="label">Reviewer:</span>
                <span class="data"><?php echo get_the_term_list( $post->ID, \'staff\', \'\', \', \', \'\' ) ?></span>
                <?php if (get_field(\'buy_link\')) : ?><span class="buy"><a target="_blank" href="<?php the_field(\'buy_link\') ?>">· Buy Now ·</a></span><?php endif; ?>
            </div>

            <div class="clear"></div>

            <div class="col3 align-right pagination">
                <?php previous_post_link( \'%link\', \'&laquo Previous Book\', FALSE ); ?>
            </div>

            <div class="col3">
                <hr>
            </div>

            <div class="col3 align-left pagination">
                <?php next_post_link( \'%link\', \'Next Book &raquo\', FALSE ); ?>
            </div>

            <div class="clear"></div>

            <div class="spacer"></div>

        </article>

    <?php endwhile; ?>

    <?php endif; ?>

    </section>
</main>
1 个回复
SO网友:Seb Szocinski

@米洛解决了这个问题——这是因为帖子是使用导入插件导入的,因此所有的日期栏都是一样的,而且每秒都会有几条!所有帖子必须有一个唯一的日期/时间,以便下一个和上一个链接起作用。

结束

相关推荐

Pagination and Related Posts

是否可以对嵌入在single中的以下相关POST代码使用分页。我的主题的php。 <?php // for use in the loop, list 5 post titles related to first tag on current post $tags = wp_get_post_tags($post->ID); if ($tags) { $first_tag = $