Showing part-posts on your WordPress home page: the "more" tag

Another Google-inspired quickie. ;-)

If you have a theme that normally shows full posts on the front page and archive pages, sometimes you'll want to change that behaviour just for a single post: perhaps it's just too long for the front page, perhaps it's got material in it that you want to warn people about before it's suddenly in their face, perhaps a cliffhanger-style cut suits the style of what you're writing. That's where the more tag comes in.


Creative Commons License photo credit: brndnprkns

One of the buttons on the WordPress new post box is labelled "more". Click it, and the tag <!--more--> appears in your text box. Once the post is published, on the home page, that tag will translate into a "more..." link, automatically cutting your post at that point. When the link's clicked, it goes to the single post page at the point in the post where the "more" tag was inserted - so your readers won't have to scroll through text they've already read.

Changing the link text

If you don't like the "more..." link text, it's easy to change. Go into Appearance > Editor, and open up index.php (you'll need to do this for archive.php and search.php too, if you have them and want them to work the same way). Look for a line similar to <?php the_content(); ?>Add the text you want inside the brackets, enclosed by single quote marks:<?php the_content(' ... read the rest of this post ... '); ?>If you want to use inverted commas in the link text, you'll need to escape them with slashes: <?php the_content('Don\'t you want to read the rest of this post?'); ?>

Alternatively, if you want different text for each individual post, edit the "more" tag each time. For example: <!--more click here if you really want to see a gross picture -->would give you link text of "click here if you really want to see a gross picture".

Removing the link text

If you don't want a link at all to the rest of the post (in which case, would you leave me a comment explaining why - most curious), you can change the the_content link in index.php etc. to<?php the_content('',TRUE,''); ?>

Share this post:
  • email
  • del.icio.us
  • Facebook
  • FriendFeed
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Twitter

Tags: , ,

Posted by Sue on May 5, 2009 in WordPress.

Leave a Reply