How to Add Excerpts to Your Pages in WordPress
Why You May Want to Add Excerpts to Pages in WordPress?
WordPress comes with posts and pages as two default content types. Posts are displayed in reverse chronological order (latest to oldest) on your blog or homepage.
Pages on the other hand are stand alone content not published in a time specific order. They are typically used for one-off content like your about us or contact page.
Sometimes you may need to display excerpts for your pages. Specially if you have built a site using only pages.
Let’s take a look at how to add excerpts to your pages in WordPress as well as how to display those excerpts on your site.
Adding Excerpts to Pages in WordPress
First you need to add the following code to your theme’s functions.php file or a site-specific plugin.
This code modifies the default WordPress content type ‘page’ to add support for excerpts.
You can head over to create a new page or edit an existing page. Below the post editor, you will be able to see the excerpt meta box.
Now you can use this excerpt meta box to add custom excerpts for your pages in WordPress.
Displaying Excerpts for Pages in WordPress
There are many different ways to display excerpts for your pages in WordPress. Depending on what you are trying to do on your website, you can choose the method that best suits your need.
Method 1: Display Recent Pages With Excerpts Using Shortcode
This method allows you to create your own custom queries and display recent pages using a shortcode.
First you will need to install and activate the Display Posts Shortcode plugin. For more details, see our step by step guide on how to install a WordPress plugin.
Upon activation, you need to edit the post, page, or widget where you want to display recent pages and add the following shortcode.
This shortcode will display the 10 recent pages with their title, excerpt, and a continue reading link.
If you didn’t enter the custom excerpt for a page, then it will automatically generate the excerpt for the page with the default length of 55 words.
If you are using the shortcode in a sidebar widget, then you may need to enable shortcode support for text widget. Simply add this code in your theme’s functions.php file.
Method 2: Display Page Excerpts in Sidebar Using Plugin
This method allows you to easily display recent pages and their excerpts in your theme’s sidebar.
First you need to install and activate the Ultimate Posts Widget. For more details, see our step by step guide on how to install a WordPress plugin.
Upon activation, you need to visit Appearance » Widgets page and add the Ultimate Posts Widget to a sidebar. First you need to provide a title for the widget and then switch to the Display tab.
Next, you need to select the ‘Show excerpt’ option and then switch to the filter tab.
On the filter tab, select ‘Page’ under the post types section and then click on the save button to store your settings.
You can now visit your website to see the widget in action.
Method 3: Display Page Excerpts Manually
Another way to display page excerpts is by adding the code directly to your theme files. You can create a custom page template and add the following code as an starting point.
You will need to adjust the code to match your theme templates.
That’s all, we hope this article helped you learn how to add excerpts to your pages in WordPress. You may also want to see our guide on how to create custom WordPress layouts with Beaver Builder.