Pretty Simple: web, digital, social



I only just discovered that WordPress has a built-in quicktag for identifying excerpts of posts, to be displayed on the homepage (rather than showing the entire post). For many of you this will be old news, but for those of you who aren’t, read on…

The WordPress codex has all the info you need about excerpts – see customizing the Read More for details. In essence, you can use the Excerpt field when authoring a new post, then modify your template to display excerpts rather than full posts.

There is a simpler way, though, via the use of the More quicktag. Simply insert the quicktag after your first paragraph (or wherever you wish the homepage excerpt to end) and it will automatically insert a ‘more’ link at the end of the excerpt, which links you to that point in the actual post. There’s even a button on the WordPress publishing interface to insert the quicktag:

The More quicktag button

The 'More' quicktag button in WordPress

Brilliant. But there’s a catch…

More quicktag and accessibility

Depending on your index.php template, the text of the link which this generates may not be fully accessible. It’s quite probable that it will simply say something like “Read the rest of this entry” after each excerpt – and we all know that this is no good (if you don’t know, imagine a screen-reader user tabbing through your links out of context. They’re not going to know which post each link refers to… “read more of which entry!?”).

The WP codex does address this, but it’s a way down the page. So for your convenience, here’s the solution…

Making it accessible

Simply go to your index.php template and change the code to insert the title of the post.

Before:

<?php the_content(“Read the rest of this entry ยป”); ?>

(or similar)

After:

<?php the_content(“Read the rest of ” . get_the_title(”, ”, false)); ?>

Pretty simple isn’t it!?

See the Pretty Simple blog homepage to see this in action.

PS – the solution isn’t perfect as it doesn’t appear to automatically apply to other pages where you collate posts (such as those generated by tags or from an archive of a previous month). There’s yet another solution – simply add custom text inside the More tag itself. For example, writing a More tag like this <!–more Read more about the More tag –> will produce link text of “Read more about the More tag” in every situation. It will override the insertion of the post title, although the previous solution is a useful back-up if ever we forget to add the custom text to the More tag.

PPS – actually, I may start using the proper ‘excerpt’ function soon – it seems much better for hand-crafting relevant and enticing summaries.

Was this post useful? Did I miss something? Let me know – leave a comment!

This entry was posted in Blog and tagged , , . Bookmark the permalink.

5 Responses to Making WP’s Read More quicktag accessible

  1. Ben Millard says:

    On Calthorpe Park School we don’t use WordPress but we have a similar IA/UI scenario. On the homepage, we simply remove “Read more” type links because the heading is a super-visible link already.

    Your technique here can also be improved by avoiding repetitive text at the start of such links.

    Make “Read more [about]” into normal text and so only the “[article name]” part is the link. This way, identical destinations get identical link text without a repetitive phrase at the start.

    (I’m assuming these comments allow HTML…and that I typed it correctly!)

  2. James says:

    Good points Ben – I’m definitely leaning towards the second technique that I mention, where you can customise the link text completely rather than leaving it to be generated automatically. That way I can be sure of avoiding repetitive text.

  3. Gary Miller says:

    @James:Great post! What I can’t figure out is this: I’m using the Seabeast theme. If I have a short post, I don’t want a ‘More’ link, but it gives one anyway. I’m going crazy trying to figure it out!

  4. Gary Miller says:

    James, tried that but I can’t make head nor tail of if! Thanks for trying though…still looking.

Leave a Reply

Your email address will not be published.

Browse by Category