Controlling the ‘Read More’ Message in a Wordpress Template

Wordpress displays the latest articles on the front page of your blog – which can result in a very long first page!  You can use the <!–more–> tag to control what is displayed on the first page.  This blog has a separately written summary of each article for example. You may also want to control the message that links to the full story. 

This article explains how to control the “read more” message in your Wordpress blog.

One of the things I didn't like about the Wordpress template I've been using for Dougs Travels, is the way it handles long articles on the main page. 

In Wordpress, you can control where to break a long article, but placing the <!–more–> tag just where you want the page break to appear.  There is a caveat to this technique: you must either use the "more" button in the Wordpress editor toolbar, or place the more tag in the HTML, outside of the text (i.e. between <\p> and <p> tags, or after one paragraph ends, and before the next begins).

This will cause an excerpt of the paragraph to appear on the first page, and a message saying something like "Read more" to be printed as a link at the end of the paragraph. 

I didn't like the way the "Read more" message was displayed.  The message began where the paragraph left off.

My solution was to edit the code that prints the "Read more" message in the template.  This is actually really easy, and you needn't leave the template to do it.

In your template, there is a snippet of code to generate the post extract, and the "Read more" message:

    <?php the_content('Read more'); ?> 

I changed it as follows:

    <?php the_content("… \n<B>Continue reading</B> …"); ?>

The result is that it prints "…" at the end of the excerpt, then, on a new line (\n generates a new line), it prints "Continue reading …" (in bold, because of the <B></B> tags).


No comments:

There are no comments for this post so far.

Post a comment