0

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 -->
1

Try this, nice and simple:

<?php next_post('%', 'Prev: ', 'yes'); ?>
<?php previous_post('%', 'Next: ', 'yes'); ?>
  • 1
    These functions are deprecated and may stop to work eventually. – fuxia 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
1

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>
  • 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
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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