writingwell
Member
Posted 2 years ago #
How do I use the Previous Post/Next Post functionality so that
- my "Previous post: " and "Next post: " text is NOT part of the link, so I can style it,
- the post titles ARE links,
- and everything works automatically as usual with WordPress?
I love the implementation on Steve Bauer's blog HowToMasterNLP.com, and would like to do something similar. Scroll down to the bottom of this page to see an example.
What theme are you using? Can you post a link to your site?
writingwell
Member
Posted 2 years ago #
My blog is Living Well NLP.
I use a modified WP-Andreas01 theme.
Here's the code I currently use on the Single Post template (single.php):
<div class="navigation">
<p><span class="prevlink"><?php previous_post(); ?></span></p>
<p><span class="prevlink"><?php next_post(); ?></p>
</div>
writingwell
Member
Posted 2 years ago #
...and yes, I deliberately use the "prevlink" style on both Previous and Next links. ;-)
I'm guessing a little here, but is this what you want?
<div class="navigation">
<p><span class="prevlink">My Previous Post: <?php previous_post_link('%link'); ?></span></p>
<p><span class="prevlink">My Next Post: <?php next_post_link('%link'); ?></span></p>
</div>
See this reference.
http://codex.wordpress.org/Template_Tags/previous_post_link:
use <?php previous_post_link('%link'); ?> to get just the link;
write your fixed text infront of it.
workaround for the the first and last post:
(thanks to: http://digwp.com/2009/12/optimizing-wordpress-post-navigation/ ) - i leave it to you to get your formatting around it ;-)
<?php if(get_adjacent_post(false, '', false)) { echo 'Next article: '; next_post_link('%link'); } ; ?>
<br />
<?php if(get_adjacent_post(false, '', true)) { echo 'Previous article: '; previous_post_link('%link'); } ; ?>
@vtxyzzy:
i had my editing window open, so i missed your reply.
searching and reading the codex always helps ;-)
@alchymyth - like your answer with the first/last post workaround.
not mine - credits go to Jeff Starr ;-)