• mrsamdk

    (@mrsamdk)


    I have the following scenario:

    I’m reading a post which is connected to one category.

    In this post im able to browse previous and next post.

    My problem is, that when i’ve browsed the few post in this category, the browse will go on to post from other categories.

    Am I able to ONLY browse the post from the category which the post belongs to.

    My browsing links looks like the following:

    <div id="nav-above" class="navigation grid_16">
    					<div class="nav-previous"><?php previous_post_link( '%link', '<div class="meta-nav">' . _x( '&laquo;', 'Previous post link', 'twentyten' ) . ' %title</div> ' ); ?></div>
    					<div class="nav-next"><?php next_post_link( '%link', '<div class="meta-nav">%title ' . _x( '&raquo;', 'Next post link', 'twentyten' ) . '</div>' ); ?></div>
    				</div>
Viewing 3 replies - 16 through 18 (of 18 total)
  • DUDE (you are a dude, right?)!!! You’re a genius! That last snippet you sent works perfectly, without any tweaking.

    So, if you’re going to rework the article, here’s my feedback:
    1. the code you say to put in functions.php works just fine, with those comment segments fixed.

    2. The new code for single.php (which you posted above) also works great without any changes.

    3. The code segment in archive/category.php has one hiccup, I think. When I use the following line:
    $permalink = add_query_arg('stayincat', get_query_var('cat'), $permalink);

    It doesn’t work for some reason. However, when I switch that second $permalink to get_permalink(), it functions properly.

    Thanks again! Hope that hopes. ??

    *helps.

    Gods, I’m tired. Thanks again. You saved me several hours of frustration.

    Many thanks for debugging my code!! I really appreciate it.

    I had set $permalink earlier with get_permalink(), but neglected to include that line. Fortunately, the correct code is in the pastebin link.

    Sincere apologies.

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘previous_post_link AND next_post_link – browse ONLY in same category’ is closed to new replies.