Home Home » Wordpress » Blog Display-Using The More Tag

Blog Display-Using The More Tag

Question

How to display one full post on home page and sections on other pages such as archives page and categories page.

Answer

Enter the more tag in your posts at the point in which you prefer. The more tag looks like this.
The more tag
Note: Do not put any whitespace between the tag otherwise it will not work.

Go to the settings section in your admin and then to the reading section. Change the blog pages shown at most setting to display the number of posts per page to suit your requirements.

Add the following code below get_header() at the top of your index.php page in your theme template.

1
2
3
<?php if (is_home()) {$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("showposts=1&paged=$page");
} ?>

Whilst you have your index.php open look for the_content(); and make sure it is empty like this

1
<?php the_content(); ?>

Then go to your archives.php and/or categories.php (if you have one) and enter the following.

1
<?php the_content('Read More >>'); ?>

You can change this to suit your requirements

Thats it you should now have one post on your main blog page and small sections of posts on your others. Just don’t forget to add the more tags to your posts!

The more tag is supposed to be ignored on the homepage if this method doesn’t work then we will set it manually.

In index.php

Declare the global $more underneath get header().

1
<?php global $more;?>

Then add the following above the_content();

1
$more = 1;

For further reading about the more tag visit customising the read more and Template_Tags/query posts on the wordpress codex.

Related Posts

Share This Post

Delicious StumbleUpon Twitter Facebook Technorati DZone

One Comment

  1. Nick Prignano

    12th March 2009

     

    Awesome. While you didn’t write this post specifically addressing my issue, your method definitely resolved it. I was having an issue with showing a single post on my frontpage and the other methods I tried broke the previous/next links. Your method allowed me to show one post on the front page and the paged navigation links still work. Thanks :)

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment.

© 2010. World O Web. All rights reserved.