How to Change Default Next and Previous Links in WordPress

I’m using Twenty Eleven wordpress theme, and the default labels for the previous and next post links are “Previous” and “Next“. So, instead of that ugly labels, I’d like to change it to post title. Here’s how to do it.

Go to theme editor, it’s in Appearance -> Editor, and click the Single Post (single.php).

Find this line:

<span><?php previous_post_link( '%link', __( '<span>&larr;</span> Previous', 'twentyeleven' ) ); ?></span>

and change the word Previous to %title so it become like this:

<span><?php previous_post_link( '%link', __( '<span>&larr;</span> %title', 'twentyeleven' ) ); ?></span>

As for the next link, you need to find this line:

<span><?php next_post_link( '%link', __( 'Next <span>&rarr;</span>', 'twentyeleven' ) ); ?>

and change the word Next to %title so it become like this:

<span><?php next_post_link( '%link', __( '%title <span>&rarr;</span>', 'twentyeleven' ) ); ?>

Done. Save the file by clicking the Update File button. Now you can see that those ugly labels are changed to post title.


Previous Link - Before

Previous Link - Before


Previous Link - After

Previous Link - After