Become Wordpress Professional - Your Ultimate Wordpress Guide

Saturday, 8 June 2013

Changing Read More Link for Excerpts in Wordpress

By Default the wordpress read more link for excerpt somewhat looks like this "[...]" which means the full content is not being displayed but a short chunk of content is visible which we might call as a teaser.

We can change the Read More symbol or make it link to it's particular post or set whatever text that we like to have such as Continue reading, Full Article , View Complete Post etc.

To change the default read more link for wordpress, first of all log in to the backend and open up your current theme's functions.php file.

Next we need to write a function that will alter the default read more symbol and will output a read more link of each particular post respectively. Then we simply need to add a filter to let wordpress know that we want to use the altered read more instead of the default read more in wordpress.
function my_custom_read_more($more){

return ' <a class="more-link" href="'. get_permalink( get_the_ID() ) . '">Read More</a>';

add_filter( 'excerpt_more', 'my_custom_read_more' );

The above function simply returns an HTML link tag to the particular post. Note that we have attached a class to the link. We can use this class to define styles to the link in the theme's stylesheet according to our requirements. The filter is the hook that tells wordpress about the change we want in the read more link of our excerpts.


Post a Comment

Please Avoid Spamming. Comments will be moderated before they are published.