previous/next post links
-
I have just upgraded from 2.9.2 to 3.0.5
Everything appears to be in order except the previous post/next post links above each post. These links used to appear only on the expanded post and not on the main page. What do I need to change in the coding so these links will show only on the actual post page?
Here is the coding I have now:
<!-- start prev/next posts --> <div class="pstlnk"> <?php previous_post('<b>«</b> % <b>«</b> ', '', 'yes'); ?> <?php next_post(' <b>»</b> % <b>»</b>', '', 'yes'); ?> </div> <!-- end prev/next posts -->I hope the question makes sense.
-EMorris, Firefox 3.6.8, WinXP, WP3.0.5
-
Just to clarify, I am trying to get the previous post/next post links above each post never to appear on the index page.
Here is the site: etherwork.net/blog/ «« I have purposely left that unlinked, in an attempt to keep spammers at bay.
-E
sigh… please excuse me for replying to myself yet again.
I just noticed that I was using the now deprecated tags
previous_postandnext_post(http://codex.wordpress.org/Function_Reference/previous_post). I have now changed the coding on my index page to read the following – it is within the loop.<?php previous_post_link('<b>«</b> %link <b>«</b> '); ?> <?php next_post_link(' <b>»</b> %link <b>»</b>'); ?>Irritatingly, the links are still showing on the index page.
Just to reiterate, what must I do to get those links to show ONLY on the post page and not on the main blog page?
-EMorris, Firefox 3.6.8, WinXP, WP3.0.5
etherwork.net/blog/ «« I have purposely left this unlinked, in an attempt to keep spammers at bay.
Excuse me for replying to myself yet again. Because I did not receive any replies to my questions, I continued googling and searching. While it might not be the most elegant or perfect solution, I do think it works.
MichaelH suggested to “edit the single.php” in a reply to the thread Display text on one post and one post only?
My theme didn’t have a single.php file but now it does. I have removed the following coding from my theme index.php and put it onto the newly formed single.php
<?php previous_post_link('<b>«</b> %link <b>«</b> '); ?> <?php next_post_link(' <b>»</b> %link <b>»</b>'); ?>This will work well for now. I’ll stare at the following to see if there is a tidier way. http://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page
-E
I looked a little more at http://codex.wordpress.org/Function_Reference/previous_post_link and have now altered the coding to the following (I remembered to fix the character entities and make sure they ended with semicolons):
<?php previous_post_link('%link', '<b>«</b> %title <b>«</b> ', FALSE, '7'); next_post_link('%link', ' <b>»</b> %title <b>»</b>', FALSE, '7'); ?>And hey presto, the previous/next post links (with the exception of any links to posts in the #7 category) are showing up only on the actual post pages. Yay!
The topic ‘previous/next post links’ is closed to new replies.