How to display excerpt and complete content in WordPress

Sunday, December 6, 2009, 1:38 AM | 1 Comment

The question of “how to display excerpt and complete content in WordPress” has been asked probably more than we care to hear and answers given perhaps more than we care to listen. In one of the discussion forums that I have joined, a participant wanted to know how she could display excerpts of a post on her ‘Home’ page and that if the blog visitor wanted to continue reading, how she would attempt to code it so the visitor would be able to read the complete article.

The following is yet another attempt to go about the task. This is actually what I have implemented on my WordPress blog.

Conditions used
There are some conditions we have to use which are as follows:


Algorithm used
If individual post has been clicked, display complete content
After the content is displayed, I then display
some messages

else display excerpt of the article and display a
click-able indication for continue reading…

<?php if (is_singular()) : ?>
	<?php the_content();  ?>

<?php else : ?>
	<?php the_excerpt();  ?>
	<strong><?php _e('<a href="'.get_permalink().'">
	Read More »'); _e('</a>'); ?></strong>

<?php endif; ?>

In addition, on the Home page, because I have several
posts  in the form of excerpts, I like to have Google
AdSense after the excerpts of the first post only and
after that no AdSense. I treat category and Home similar
and display AdSense after the complete content as well.

Therefore I give the following conditions:

If this is (single post or (first post and 
(home or category)) and not page) 
then display Adsense ads

<?php if (is_singular() || ($post==$posts[0]
&& (is_home() || is_category())) && !is_paged()) { ?>

	Here I display AdSense ads

<?php } ?>

I then like to display a line per postmetadata
defined in style.css to make the distinction (separation)
between excerpts.

<p class="postmetadata"></p>

If you just want to display the complete content skipping the excerpt like some blogs do, then instead of all the conditions as stated above, you would just have the the_content() in your code.

Throw us a like at

  1. One Response to “How to display excerpt and complete content in WordPress”

  2. By diets that work on Jun 28, 2013, 8:00 pm | Reply

    Useful information. Fortunate me I discovered your site by chance, and I am shocked why this twist of fate did not happened in advance! I bookmarked it.

Post a Comment on Content of the Article


This is not a billboard for your advertisement. Make comments on the content else your comments would be deleted promptly.

CommentLuv badge