How To Display Excerpt In WordPress Theme In Place Of Content?
August 27th, 2016 | by Ravi Chahar || 8 Comments |
In the previous post, I have mentioned how to add excerpt in WordPress from the admin area. There are many people who want to show the excerpt in place of the full content in their WordPress theme. You can do that by editing the theme file.
WordPress is an amazing platform and you can play with it. The WordPress themes consist the PHP codes and if you have a little bit of knowledge about PHP then you can change the theme functions.
What’s The Importance To Display Excerpt In WordPress?
You may have noticed that when you visit any website then there may be many posts with a few lines of description and then the read more button appears. It improves the user-experience.
It would help you to reduce bounce rate of your website because the people will engage more and like to see the archives page including the categories of your posts and more.
Instead of looking the whole content of every post, readers like to grab the description and then decide to read the full post.
Most of the WordPress theme developers prefer to add the excerpt in WordPress themes instead of showing the whole content. They provide the inbuilt feature to their users.
How To Add Excerpt in WordPress Theme?
When it comes to edit the theme files and then you should always backup the website and the database. It’s because sometimes a little piece of code can break your whole theme.
To add excerpt in WordPress theme, you have to edit the “index.php” file. There are a few steps to follow.
Step 1:- Login to your cPanel and open the file manager.
Step 2:- Search for the “wp-content” folder where all the plugins and folders are present.
Step 3:- There would be a folder with the name “Themes” in which you have to search for the name of the theme you are using.
Step 4:- Many files and folders would be there from which you have to right click on the “index.php“. Click on edit and the code will appear to you in a new tab.
Step 5:- If you are aware of the PHP coding then it won’t be so hard for you. But if are not tech savvy then just find a line of code.
Replace it with :-
Save the file and you are ready to go. You will see the excerpt has been added in your theme and from now onwards you don’t need to add the read more button manually. Your WordPress theme would pick it up.
This will display excerpt in WordPress blog page, not all other pages. If you want to edit the categories, search results then you have to add it in the “archive.php” which would let your theme to show the description with all the posts.
Every developer has his/her own style of writing the codes and if you are not aware of WordPress theme’s structure then it would be difficult.
But the simple thing is to change the code in the “index.php” file which would solve your problem for the blog post page.
Can You Add Excerpt In WordPress Theme Now?
Though it won’t be so hard to replace the code. You just have to find the file and paste the code mentioned above. It is the WordPress default feature to capture the description after adding the excerpt code.
Instead of showing the full content, you can add excerpt in WordPress posts and pages. There is another option which carries the brackets at the end of the excerpt. But for now, you don’t need to worry about that. If you still face any problem then feel free to ask.
Thank you sir for sharing this helpful ideas and tell me how to add Excerpt in WordPress theme briefly.
I am glad to help you. You can learn a lot more about the WordPress CMS. It’s all about how you configure it.
Thanks for your comment.
Enjoy the day.
It’s great post. Especially for those who aren’t good in coding like me.
Thanks for sharing.
– Umesh Singh
There is nothing hard to edit the PHP codes. Just have a little bit of knowledge and you will be able to edit all the files of WordPress.
Thanks for taking the time to be here.
Have a great day.
Willing to read your excellent post,
You have explored great importance about excerpt in WordPress. I really agree with you almost audience believed in good description and then they decide to read whole post.
Steps of adding excerpt in WordPress theme is really appreciable and you have simply tried to make us understand about whole mechanism of adding excerpt, its genius and it is informative in nature. It will really helps in maximizing productivity of websites and makes it attractive to audience.
Eventually, thanks for sharing your worthy post.
With best regards,
WordPress has a lot more to learn and you can do many cool things with it. It’s good to know that you have the sense to adapt the knowledge of WordPress. Learning is always great.
Adding the excerpt in your WordPress theme can be challenging if you don’t know anything about WordPress. But just a little bit of code and you can change the appearance.
Thanks for stopping by.
Have a great day.
I have used this way a lot in the early days when I was learning WP stuff, and when I had to make full post on homepage to excerpt.
Thanks for the post. It reminded the old days but still it is useful.
For beginners, these types of things are necessary to use. There are many people who struggle to add these things. Just a one line code can help them to show the excerpt instead of the full content.
I am glad that I could make you remember.
Enjoy the day.