WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working with a site that is displaying a portfolio CPT on the home page in a "Grid Loop." On the single pages, i'd like to add Previous & Next Item buttons. I thus added this code:

function custom_post_navigation()
    <div class="prev_next">
        <div class="nav_left">
            <span class="prev"><?php previous_post_link('%link', 'Previous Item</span>'); ?>
         </div class="nav_right">
            <span class="next"><?php next_post_link('%link', 'Next Item</span>'); ?>

add_action('genesis_before_post_title', 'custom_post_navigation');

On the site Safety Warehouse It now displays the links properly on the single item pages, but It is also displaying Previous and Next buttons on the home page as well.

How can I remove them from the home page?

share|improve this question
up vote 2 down vote accepted

I'm not familiar with Genesis, but I assume you can wrap the output of your function in a check if is_single():

function custom_post_navigation()
    if( is_single() )
        // output next/prev links
share|improve this answer
That fixed it. Thanks a ton! I didn't realize you could use the is_single() conditional on CPTs. – Zach Russell May 29 '13 at 22:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.