Do you want to add excerpts to your WordPress pages?
Excerpts are short extracts from your content and help add a description, summary, or small details about the page. By default, excerpts in WordPress are only available for posts.
In this article, we will show you 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. Especially if you have built a WordPress site using only pages.
Let’s take a look at how to add excerpts to your pages in WordPress and 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.
add_post_type_support( 'page', 'excerpt' );
This code modifies the default WordPress content type ‘page’ to add support for excerpts. For more details, please see our guide on how to add custom code in WordPress.
After adding the code to your website, you can head over to create a new page or edit an existing page. Once you’re in the WordPress content editor, you’ll be able to see the ‘Excerpt’ meta box in the panel on your right.
Now you can use this excerpt meta box to add custom excerpts for your pages on your WordPress blog.
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.
[display-posts post_type="page" include_excerpt="true" excerpt_more="Continue Reading" excerpt_more_link="true"]
This shortcode will display 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 the text widget. Simply add this code to your theme’s functions.php file.
// Enable shortcodes in text widgets
add_filter('widget_text','do_shortcode');
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 MK Post and Page Excerpts Widgets. For more details, see our step-by-step guide on how to install a WordPress plugin.
Upon activation, you need to visit the Appearance » Widgets page and click the ‘+’ button to add the MK Post and Page Excerpts Widgets block to a sidebar.
After adding the widget block, you can select your page from the dropdown menu under Select Page.
There are also options to edit the title, choose whether to display the page title, content, set content length, featured image, and more.
When you’re done, click the ‘Update’ button at the top. 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 a starting point.
$args = array(
'post_type' => array( 'page' ),
'posts_per_page' => 10,
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<h3>'. get_the_title() . '</h3>';
the_excerpt();
}
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
You will need to adjust the code to match your theme templates.
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 choose the best website builder or our expert pick of the best live chat software.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
marcelo araujo says
Hi, great tip. Tks a lot! Its possible to use same param to get “tags” in pages?
add_post_type_support( ‘page’, ‘excerpt’ );
like:
add_post_type_support( ‘page’, ‘tags’ );
its correct? it works?
Tks!
WPBeginner Support says
To add tags and categories to pages, we would recommend taking a look at our article below!
https://www.wpbeginner.com/plugins/how-to-add-categories-and-tags-for-wordpress-pages/
Admin
Jim Kernicky says
Easy as pie – thanks a lot for that!
WPBeginner Support says
You’re welcome
Admin
Jean-Louis says
It’s very helpful… Thank you so much!
WPBeginner Support says
Glad our article was helpful
Admin
Adam says
So, I can’t find the “excerpt” option under “screen options” on the post/page editing page. I added the code to my functions.php file and the option to include the ‘excerpts’ is still not showing up. It’s as if the excerpts function doesn’t even exist on my install of wordpress. I added the following code and nothing changed:
add_post_type_support( ‘page’, ‘excerpt’ );
Please help
Juan Manuel Linares says
Thanks so much, it also worked for me, just when I needed it!
It would also be advisable that you suggest ppl to check Screen Options (as CTGIRL said), ’cause in my case it was hidden there
Thanks anyway!
Steve says
Is there a way to add an excerpt to an archive category page like with the code for pages? The following code worked great for pages. Wanting to add it to the category archive too.
add_post_type_support( ‘page’, ‘excerpt’ );
Ruth Billheimer says
Thank you so much! This is excellent and just what I was looking for.
Atilla says
Thank you for the code!
Djong Timoer says
I works !!
Thank you
Do you have idea how to use in post types?
Manoj says
Thanks for the code .But if i don’t write content in excerpt section , Excerpt is not retrieving from editior .
Amit kumar says
how to separate post excerpt in box
Toure says
How can it be added to a page template?
nad ray says
You should wrap the code in :
…for it to work and not make your site break/display a blank page.
Reza says
How can I add excerpts to the events? Can anyone please help?
nad ray says
I would use the same code, but change page to events (line 3). If that does not work you need to find your events custom post type name and enter it instead of pages.
ctgirl says
The code worked for me. Added it to functions.php, and the Excerpt field became available in Screen options. Thanks so much!
kapil says
around 15 days ago, same above code work perfectly for me, but now it is not working, what may be the problem, can anyone help me ? above code doesn’t show excerpt place in admin panel for new website that I am developing right now.
Firda says
It’s working for me. Maybe the exceprt was hide by screen options?
João G. says
That’s amazing! I got a job to change the layout of a website which is running on WP and I would have to search for a function to get the content with “strip_tags” and reduce characters, but after “googling”, found your post. Great !!
Real name says
Tank’s
codex.wordpress.org/Function_Reference/add_post_type_support#Example
Julio says
Thanks! worked perfectly
Dave Andrew says
Worked a treat. Thanks for the post.
Owen says
Thanks your sharing
Lins says
Thanks, super-handy & works easily.
syndrael says
Thanks it works..
Alastair Barnett says
Hello,
I posted the above code to my functions php. I now cannot access my website. Here is the message I receive:Parse error: syntax error, unexpected T_FUNCTION in /home/content/94/8738594/html/wp-content/themes/associate/functions.php on line 82
Please tell me how I can access my website in order to delete this code. Thanks if you can help. I’ve just lost my website and in a bit of a panic. Website address: http://www.thewritingbutler.com
AB
Editorial Staff says
You pasted the code in a wrong place. Here is an article that you should consider before pasting any code from any website:
https://www.wpbeginner.com/beginners-guide/beginners-guide-to-pasting-snippets-from-the-web-into-wordpress/
You will have to use FTP to fix it.
Admin
WK says
Added the code to my functions.php to enable excerpts on my pages.
Worked perfectly, first time – thanks.
W.
mebhuwan says
Thank you for posting. Great Code.
mattrock says
A very handy function. Thanks for posting!
DanS says
Brilliant, thank you
softboxkid says
no need any plugins… just place this
add_post_type_support( 'page', 'excerpt' );
to your functions.phpEditorial Staff says
Thanks for adding this code. We will update the post soon.
Admin
ghimeray says
How to get this excerpt into the page?
Tne Excerpt function is working well, but i’m not able to get the excerpt into the front page.
adam says
This didn’t work for me. Still no excerpts option. Using default 2015 theme.