• I’m trying to build the navigation for a custom post type (i.e. portfolio) and having some trouble with get_boundary_post that I’m not understanding. My template displays the current post (singly) and I’m able to successfully use the get_adjacent_post function to handle the links previous and next posts . . . but I cannot get the first and last links to work properly to save my life.

    <?php
    /* get first, previous, next and last posts */
    $theFirstPost = get_boundary_post(true,"",true);
    $theNextPost = get_adjacent_post(false,'',true);
    $thePreviousPost = get_adjacent_post(false,'',false);
    $theLastPost = get_boundary_post(true);?>
    . . . .
    
    <div>[ <a href="<?php echo get_permalink($theFirstPost); ?>">First</a> |
    <a href="<?php echo get_permalink($thePreviousPost); ?>">Previous</a> |
    <a href="<?php echo get_permalink($theNextPost); ?>">Next</a> |
    <a href="<?php echo get_permalink($theLastPost); ?>">Last</a> ]</div>

    At first, I thought get_boundary_post just wasn’t able to return a post object from a custom type– but when I specifically checked with is_null() or empty(), both $theFirstPost and $theLastPost do not trigger if statement with that criteria. I even tried $theFirstPost->ID inside of get_permalink, just in case I wasn’t being as specific as possible. It’s almost as if it’s returning a post object that has no permalink associated with it, and then defaults to the value of the current post.

    Is there some quirk to get_boundary_post I’m not aware of? Or am I overlooking something really obvious?

  • The topic ‘Custom Post Types and get_boundary_post’ is closed to new replies.