I nearly always make a custom excerpt for every post I write. This has the benefit of letting my lede be extended into a great sub-headline. It has the downside of killing my ‘Read More’ links.

The objective is simple. Have a custom excerpt and a read more link. The problem is that there are multiple excerpts and WordPress handles them all in different ways.

  1. The teaser – This is what you write in a post and end with a <!--more--> tag.
  2. The automatic excerpt – This is the first 55 words of a post.
  3. The custom excerpt – This is what you put in the ‘excerpt’ box on a post.

Those are parsed in reverse order, so the custom excerpt is given the highest priority. That means in order to show my read-more links, I need to put this in my theme’s function.php file:

function new_excerpt_more( $more ) {
	return ' <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More', 'your-text-domain') . '</a>';
add_filter( 'excerpt_more', 'new_excerpt_more' );

But. I’m using StudioPress’ Genesis theme. This means I’d like to take advantage of some of the awesome accessibility friendly features so that my read more link looks like this:

<a href="http://example.com/cookies-and-cake" class="more-link">Read more<span class="more-link-title screen-reader-text"> about Cookies and Cake</span></a>

Okay, cool. How do I do that? Back in the old days, this was how you’d edit the link for Genesis:

//* Modify the WordPress read more link
add_filter( 'the_content_more_link', 'sp_read_more_link' );
function sp_read_more_link() {
	return '<a class="more-link" href="' . get_permalink() . '">[Continue Reading]</a>';

As of Genesis 2.2, we’re into a world of properly accessibility friendly code, and the function get_the_content_limit() has a major change where it calls genesis_a11y_more_link and that is the function that added in the span for the screen-reader, which requires me to add in the genesis-accessibility theme support for my theme.

// Customize the read-more links in all situations
add_filter( 'the_content_more_link', 'sp_more_link_text' );
add_filter( 'excerpt_more', 'sp_more_link_text' );

function sp_more_link_text() {
	return '&#x02026; <a class="more-link" href="'. get_permalink( get_the_ID() ) . '">[' . genesis_a11y_more_link( 'Continue Reading' ) . ']</a>';

And as far as it goes, that’s perfect. It makes sure everything matches nicely and is accessibility friendly. But it doesn’t take care of my custom excerpts. For that I need a force command:

add_action( 'genesis_after_entry_content', 'sp_force_more', 15 );
function sp_force_more() {
	global $post;
	if ( has_excerpt( $post->ID ) && !is_singular() ) {
		echo '<p><a class="more-link" href="'. get_permalink( $post->ID ) . '">[' . genesis_a11y_more_link( 'Continue Reading' ) . ']</a></p>';

If there was an genesis_after_entry_excerpt sort of function to hook into, I’d be happier, but this works. It puts a [Continue Reading] paragraph at the end of each of my excerpts for my front page, my archives, and not my individual pages. This helps my readers who are, perhaps, not always as aware as they might be about where to click.

Reader Interactions

%d bloggers like this: