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, Magento, Shopify as well of many other frameworks. Whether you need responsive design, SEO, speed optimisation or anything else in the world of digital then get in touch. If you would like to work with Nathan, simply drop him an email at [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 Load More Posts using Ajax with a Button or on Scroll in WordPress

Wordpress / 22nd January 2021

How to Load More Posts using Ajax with a Button or on Scroll in WordPress

Read More Related - The 5 Best WordPress Age Verification Plugins to Help You Add an Age Gate

Wordpress / 21st January 2021

The 5 Best WordPress Age Verification Plugins to Help You Add an Age Gate

Read More