How to Change the default Excerpt text in WordPress

WordPress Tips & TricksDid you ever get bored with the default Excerpt sign “[...]” when you are using <?php the_excerpt(); ?> function instead of <?php the_content(); ?> on your theme?

Well, I do. In fact I am so annoyed with that sign that I never ever forget to use a very little snippet code to all of my WordPress theme that I have made so far, just to get rid of that default sign.

So, If you are like me and want to change this default Excerpt sign with something else, this is the post for you. Trust me, it’s not going to take whole lots of time and it’s as easy as it can get.

All you have to do is just copy and paste the following snippet code on your theme’s functions.php file and update it.

<?php
function new_excerpt_more($more) {
global $post;
return '<a href="'. get_permalink($post->ID) . '">Read More</a>'; }
add_filter('excerpt_more', 'new_excerpt_more');
?>

If you look at the code carefully, you will find “Read More” at the end of fourth line. You can change the text with whatever you like. If you want to get little fancy, you can add an image instead of the text as well. Just simply put the image tag and add the full URL of the Image, that’s it. It would be something like this

<img src="http://www.yourdomain.com/more.jpg" />

I hope that helps. Feel free to make comments or ask questions. You can always subscribe our RSS feed to get the latest updates.

You can follow us on Twitter, add on your Google+ circle or Like our Facebook page to get the latest news, updates and reviews.

advertisement
Comments: