Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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">
        <div>
            <span class="next"><?php next_post_link('%link', 'Next Item</span>'); ?>
        </div>
    </div>
<?php
}

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.