Read More Customization

From the WIE PHP lectures, we learned how to add a “Read More” link with a permalink to a post’s full text.  When I was building, though, I ran into a couple of issues.  One, by default, the end of the excerpt ends with “[…] ” – which I wasn’t a fan of.  Second, by default the Excerpt and Read More get wrapped in paragraph tags which forces the Read More down on its own line, and despite my efforts to CSS that away and make the Read More show up after the Excerpt, I failed.

So, off to the WordPress Codex I went.  I needed to kill this guy: […] and replace it with a clickable link I could customize to send readers to the full-text version of my post.  Man, were there a lot of options on this codex page.  I was happy, however, to find that there was a function to do exactly what I wanted:

// Replaces the excerpt "more" text by a link
function new_excerpt_more($more) {
       global $post;
	return '<a class="moretag" href="'. get_permalink($post->ID) . '"> 
        Read the full article...</a>';
add_filter('excerpt_more', 'new_excerpt_more');

I just changed the “Read the full article…” part to be “…Read More” like I wanted, and I was able to achieve the look and functionality I needed.  It’s really great that there are some many customization options and great documentation for WordPress.  Usually, all it takes is a quick search and your problem is solved!