0

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?

2

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
    }
}
  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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