Ambrosite Next/Previous Post Link Plus
[resolved] exclude posts in twenty twelve (2 posts)

  1. carboneum
    Posted 3 years ago #


    in which file i have to put the code:
    <?php next_post_link_plus( array('ex_posts' => '') ); ?>

    for exluding posts for the prev/next links?
    I put the code in the single.php and the functions.php
    but the link at the bottom of each post still is there.

    Thank you.


  2. ambrosite
    Plugin Author

    Posted 3 years ago #

    For the Twenty Twelve theme, it looks like single.php is the right file to edit, however simply adding that code will not work. You need to find the following lines:

    <span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'twentytwelve' ) . '</span> %title' ); ?></span>
    <span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'twentytwelve' ) . '</span>' ); ?></span>

    And replace them with this -- be sure to put in the IDs of the posts you want to exclude:

    <span class="nav-previous">
    <?php previous_post_link_plus( array(
        'format' => '%link',
        'link' => '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'twentytwelve' ) . '</span> %title',
        'ex_posts' => '1, 2'
    ) );?>
    <span class="nav-next">
    <?php next_post_link_plus( array(
        'format' => '%link',
        'link' => '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'twentytwelve' ) . '</span>',
        'ex_posts' => '1, 2'
    ) );?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Ambrosite Next/Previous Post Link Plus
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.