-
fw190Participant
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, 4 months ago by fw190. Reason: spelling
Daniel TaraKeymasterNot 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.
fw190ParticipantI found something like this:
http://codex.wordpress.org/Function_Reference/next_post_link#Text_As_Link.2C_Without_Post_Title.2C_Within_Same_Categoryand
http://codex.wordpress.org/Template_Tags/previous_post_link
But this is too big for me to sort this by myself
fw190ParticipantBut 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.
Daniel TaraKeymasterI 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 isnext_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.fw190ParticipantSorry 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.
Daniel TaraKeymasterThank 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.fw190ParticipantThank 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.
Daniel TaraKeymasterNo 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; }
Tagged: post
You must be logged in to reply to this topic.