• Resolved randomfreeform

    (@randomfreeform)


    Hi WP-Forgers!
    I’d like to restrict the post navigation to the same category.

    In detail – I have some pages that are made by a post category…
    and one can click a post title in the page to view it alone and in full.
    At the bottom of the post are automatically created previous and next post titles
    (.nav-previous and .nav-next) but at the end of the category items they end up showing the next categories items too (don’t want that).

    I found this related info: ‘http://presscustomizr.com/snippet/restrict-post-navigation-category’… but WP-forge is setup a lil different. I looked around wp-forge’s php files and found some ‘previous_post_link’ in the single.php that might be related? Anyways, Thomas or anyone with any tips it would be much appreciated!!

    best
    Rand

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter randomfreeform

    (@randomfreeform)

    ok, live n learn… it’s related to this
    http://codex.wordpress.org/Template_Tags/previous_post_link
    and is edited in the singles.php

    It seems like all I need is ‘TRUE’ added to keep the template tag within the category..
    But after trying a few edits I haven’t had success…
    Anyone got a clue?

    thx!!!
    R

    Theme Author ThemeAWESOME

    (@tsquez)

    Hey Rand,

    Your first link you provided is for a specific theme called Customizer, therefore of course WP-Forge would not be coded the same.

    The second link you provided is to the codex and WP-Forge is coded exactly the way it shows.

    and yes you are correct, all you need to add is true to single.php. So open single.php and go line 21 which looks like this:

    <span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '&laquo;', 'Previous post link', 'wp-forge' ) . '</span> %title' ); ?></span>

    and make it look like this:

    <span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '&laquo;', 'Previous post link', 'wp-forge' ) . '</span> %title', true ); ?></span>

    then go to line 22 which looks like this:

    <span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '&raquo;', 'Next post link', 'wp-forge' ) . '</span>' ); ?></span>

    and change it to this:

    <span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '&raquo;', 'Next post link', 'wp-forge' ) . '</span>', true ); ?></span>

    once you do this you will see that by adding true, the next and previous links will be to other posts in the same category.

    I tested it locally and it works the way it should.

    Hope this helps and as always, enjoy!

    Thread Starter randomfreeform

    (@randomfreeform)

    Yeaaaa..
    that works perfectly.

    You give the best support out of any of the WP-Foundation based themes..
    thanks!!!!!!!
    R

    Theme Author ThemeAWESOME

    (@tsquez)

    Always glad to help 😉

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Restrict the post navigation to the same category?’ is closed to new replies.