Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Help! I want to change my "Previous" and "Next" post links to use the actual post titles. I have done all kinds of online research and code manipulation without any success.

I am using the Yoko theme. Here is my current single.php code. What do I need to update it to be? My website is www.thelawstudentswife.com

<div id="content">

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

        <?php get_template_part( 'content', 'single' ); ?>

        <?php comments_template( '', true ); ?>

        <?php endwhile; // end of the loop. ?>

        <nav id="nav-below">
            <div class="nav-previous"><?php previous_post_link( '%link', '' . _x( '&larr;  Previous Post', 'Previous post link', 'yoko' ) . '' ); ?></div>
            <div class="nav-next"><?php next_post_link( '%link', __('') . _x( 'Next Post &rarr;', 'Next post link', 'yoko' ) . '' ); ?></div>
        </nav><!-- end nav-below -->

</div><!-- end content -->
share|improve this question
add comment

3 Answers

Easily enough:

    <nav id="nav-below">
        <div class="nav-previous"><?php previous_post_link(); ?></div>
        <div class="nav-next"><?php next_post_link(); ?></div>
    </nav><!-- end nav-below -->

The previous_post_link() and next_post_link functions return a link which text is the title of the post.

share|improve this answer
add comment

straight from the Codex;

example:

<div class="nav-previous"><?php previous_post_link( '%link', '&larr; %title' ); ?></div>
<div class="nav-next"><?php next_post_link( '%link', '%title  &rarr;' ); ?></div>
share|improve this answer
    
Unfortunately, this does not work. Instead, it removed the "previous" and "next" links all together. Can you explain specifically what text I should copy over? Maybe that is my problem. Or can you paste what the entire code should look like? Also, I think the word 'yoko' needs to stay in there somewhere.... –  Erin Dec 4 '12 at 2:32
    
these edited lines replace the identical divs in your code; the 'yoko' bit is for translation purposes only. –  Michael Dec 4 '12 at 10:01
add comment

Try this, nice and simple:

<?php next_post('%', 'Prev: ', 'yes'); ?>
<?php previous_post('%', 'Next: ', 'yes'); ?>
share|improve this answer
1  
These functions are deprecated and may stop to work eventually. –  toscho Dec 3 '12 at 22:59
    
Unfortunately, this does not work. Instead, it removed the "previous" and "next" links all together. Can you explain specifically what text I should copy over? Maybe that is my problem. Or can you paste what the entire code should look like? –  Erin Dec 4 '12 at 2:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.