Friday, September 3rd, 2010

How to Add Read More to Post Excerpts

0

I had noticed on other blogs that when viewing category pages with the post cut down to show excerpts that instead of the post excerpt ending in [...] they were showing Read more.

This is how my post excerpts were being formatted

The LG 47SL9000 is one of the most technologically advanced HD TVs available on the market at the moment.
It offers a near-perfect marriage of form and function and if you can afford the premium that you will pay for the cutting edge technology then this LG LED TV should be a real consideration.
Slimline Panel for [...]


This seems to be the default option in the Studiopress Wordpress themes that I have been using so I popped along to the Studiopress help forum to see if any help was at hand.
As usual there was plenty but getting down to the nitty gritty would take a bit of research.

To start off with it seems that there is quick tag called more on the visual editor that I had never noticed before. A bit of a peruse over at Wordpress Codex Customising the Read More and I was instantly enlightened.
But a bit more help was needed to get this properly implemented into my blogs.
I bit more searching over at Studiopress and I was ready to have go at editing my Wordpress files.
This is what I did for the Studiopress Church Theme. I am pretty sure that it will work with the other themes.

Firstly open up the archive.php and look for this bit of code:

<?php the_excerpt(); ?>

and replace with

<?php the_content_limit(500, “”); ?>

This has the effect of making the post excerpts 500 characters long and it loses the [...] from the end of the post.

Now to finish the job off I had to go to all my posts and insert the <!–more–> tag at the point where I wanted the excerpt to finish. This is easy to do using the more button in the HTML visual editor on the edit post page.

This is how the excerpt now looks complete with the Read More linking to the post page.

The LG 47SL9000 is one of the most technologically advanced HD TVs available on the market at the moment. It offers a near-perfect marriage of form and function and if you can afford the premium that you will pay for the cutting edge technology then this LG LED TV should be a real consideration. Slimline Panel for Easy Wall Mounting Read More →

Note:
Don’t forget to insert the <!–more–> tag in a post at a place before 500 characters. If you want longer excerpts just change the number to something higher in <?php the_content_limit(500, ""); ?>

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!