WordPress / Web Development Tutorials
(Best WordPress Tutorials)

CSSHTMLJavaScriptjQueryMySQLPHPSilvaTechnologiesWooCommerceWordpress
Silva Web Designs - Blog

How to show excerpts of posts on homepage in WordPress

I was trying to show the excerpt for our homeage and we found that a lot of people are saying that by changing:-


<?php the_content(); ?>

to


<?php the_excerpt(); ?>

In your content.php file should do the trick. It may work for some people but in our case, it showed the excerpt on the homepage as we wanted, but then when you clicked on the actual post, it displayed just the excerpt without having an option to read the full post. Now there are many ways that you can fix this, here are two different methods:

1.) On our website, we wanted the homepage to show the_excerpt then when clicking on the post we wanted it to display the full post, to do this, edit the content.php and change the following:


the_content( __('Read more...', 'silva') );

to


if(is_home() || is_front_page()) {
    the_excerpt( __('Read more...', 'silva') ); 
}
else {
    the_content( __('Read more...', 'silva') ); 
}

Simply modify the code to suit your WordPress site, as ‘zilla’ is specific to our theme.

Alternatively, you can just change the_content to the_excerpt and then put < !--more-- > (without spaces) at the end of the post which will show a ‘read more’ option at the bottom of the post. We personally preferred the first option but it all goes down to personal preference.

 

Nathan da Silva - Profile

Posted by: Nathan da Silva

Nathan is the Founder of Silva Web Designs. He is passionate about web development, website design and basically anything digital-related. His main expertise is with WordPress and various other CMS frameworks. If you need responsive design, SEO, speed optimisation or anything else in the world of digital, you can contact Silva Web Designs here; [email protected]

It’s good to share

One thought on “How to show excerpts of posts on homepage in WordPress

Join the discussion

Related Posts

Related - How To Fix “Unable to connect to the filesystem. Please confirm your credentials” In WordPress

Wordpress / 16th March 2025

How To Fix “Unable to connect to the filesystem. Please confirm your credentials” In WordPress

Read More Related - How to Dynamically Add a WordPress Post Title in Contact Form 7

Wordpress / 11th March 2025

How to Dynamically Add a WordPress Post Title in Contact Form 7

Read More