WordPress.org

Ready to get started?Download WordPress

Forums

get_adjacent_post fails when using custom post types in The Loop (2 posts)

  1. jcskyrocket
    Member
    Posted 3 years ago #

    Hi,

    I'm trying to use get_adjacent_post to work with the loop, but it seems to fail when using custom post types. I'm using $query->set to include my CPTs in the loop. Found the method on Justin Tadlock's site: http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page .

    Here's my loop code:

    <?php
    if(have_posts()) : while(have_posts()) : the_post();
     $adjacent_post_next = get_adjacent_post(false,'',true) ;
     $adjacent_post_previous = get_adjacent_post(false,'',false) ;
     $post_next = $adjacent_post_next->ID;
     $post_previous = $adjacent_post_previous->ID;
     echo "Previous = ".$post_previous." Next = ".$post_next."<br />";
    endwhile;
    endif;
    ?>
  2. jcskyrocket
    Member
    Posted 3 years ago #

    Does anyone have any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic