Next post form same category?

Viewing 12 posts - 1 through 12 (of 12 total)
  • #5921
    fw190
    Participant

    Would it be possible that the next/previous post links would display posts from same category?

    I have a bilingual site and wouldn’t like to show a next post with another language πŸ˜‰

    • This topic was modified 12 years, 3 months ago by fw190. Reason: spelling
    #5929
    Daniel Tara
    Keymaster

    Not really, those links are handled directly by WordPress and there’s little control in regards to what they link to.

    Anyway, I don’t recommend using categories for different languages. Instead use a plugin like WPML or qTranslate.

    #5930
    fw190
    Participant
    #5931
    Daniel Tara
    Keymaster

    It only allows you to modify the link text, not the URL it points to.

    #5932
    fw190
    Participant

    But it states there http://codex.wordpress.org/Function_Reference/next_post_link#Text_As_Link.2C_Without_Post_Title.2C_Within_Same_Category

    that: “Displays custom text as link to the next post within the same category” so I thought that it is the thing for me.

    #5933
    Daniel Tara
    Keymaster

    I believe you are making a confusion. Tat function is next_post_link();, which displays a link to the next post INSIDE the post you are currently reading. It’s not paged navigation for post archived. The function for that is next_posts_link(); (minor difference). If what you are looking for is inner post navigation, then all you have to do is add a third parameter , TRUE like in the example. You’ll still have to edit the file manually.

    #5939
    fw190
    Participant

    Sorry for making confusions. I will try to explain again what I mean.

    Someone opens one post and reads it. Inside that post he has a link to the next and previous post in this category so if he is browsing for example bombs or missiles the next/previous post will bring him to a next post about bombs or missiles and not to the next post which was posted for example about airplanes.

    Sory again for not being able to say what I mean precisely.

    #5942
    Daniel Tara
    Keymaster

    Thank you, it is clear now.

    In functions.php you’ll find the function esplanade_post_nav();

    In that function you can find the 2 functions that display the next/previous post links. You just need to add a third parameter true to them and they will behave as you desire.

    #5944
    fw190
    Participant

    Thank you for the solution. This may sound that I’m stupid but could you post those lines so I could copy paste them, as when I was experimenting last time a had to upload the original file from source as the site wasn’t workin at all. I’m not a web developer and even such small things may couse problems for me.

    I hope that I do not make to much trouble.

    #5963
    Daniel Tara
    Keymaster

    No problem, here is the entire function:

    function esplanade_post_nav() {
    	if( esplanade_get_option( 'post_nav' ) ) : ?>
    		<div id="post-nav" class="navigation">
    			<div class="nav-prev"><?php previous_post_link( '%link', '← %title', true ); ?></div>
    			<div class="nav-next"><?php next_post_link( '%link', '%title →', true ); ?></div>
    			<div class="clear"></div>
    		</div><!-- #post-nav -->
    	<?php endif;
    }
    #5966
    fw190
    Participant

    Daniel!

    Everything works ok!

    You are absolutely the best!!!!

    #5970
    maartenvdkamp
    Participant

    Thank you, I was also looking for this!

Viewing 12 posts - 1 through 12 (of 12 total)

Tagged: 

You must be logged in to reply to this topic.