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?

1 Answer 1

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
    }
}
1
  • That fixed it. Thanks a ton! I didn't realize you could use the is_single() conditional on CPTs. May 29, 2013 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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