Customizing the <!–more–> Tag in WordPress
- Posted On: January 8th, 2008
- Filed Under: CSS, PHP, Template Tags
- Tags: more, the_content, Tips
At hackingWordPress we write A LOT of longer posts and we use the <!--more--> tag A LOT. We do that for a few different reasons.
The first reason is a practical one. Without breaking our posts off somewhere our frontpage would run on endlessly! Five back-to-back long posts would drag things out way to far. The <!--more--> tag allows us to break things up a bit and keep our front-page scannable.
On a more devious note it also helps us make our posts more clickable in our category pages, front page and even in our RSS feed. If you're subscribed to hackingWordPress you'll see that the more tag causes our a link to appear beckoning you to click through to read the post. It's a great way to get people visiting your site rather than just looking at the content in your RSS feed!
In this post we'll go over how to quickly customize your what <!--more--> displays on your blog to help get a few more visitors!
To start let's look at how the <!--more--> tag works. In it's default form <!--more--> displays something pretty plain - just "(more...)."
It's not exciting and it's certainly not very descriptive. Something like "Click here to read the rest of this post" would be much more enticing no?
Let's get to it.
To start we're going to need to open up our index.php file and locate the code that's responsible for displaying our posts content. Unlike a lot of other parts of WordPress <!--more--> doesn't specifically have it's own Template Tag, instead it's governed by the_content() which will appear somewhere inside the loop.
Now we just add 'Click here to read the rest of this post' inside the brackets. It should now look something like this:
<?php the_content('Click here to read the rest of this post'); ?>
Obviously you can add whatever text you'd like. If you've got an image you'd like to include you can also include basic HTML which is really a great addition.
The trick is to make something that's eye-catching and lets the reader know that there's more to your post than what they're currently looking at.