Adding excerpts to Pages in WordPress

Wordpress functions
Published: by

Pages is one of WordPress’ main content types, but doesn’t make use of excerpts. There are a couple of reasons why developers might need this field in WordPress pages. This post will show you how.

This is an ongoing post. Please suggest corrections, explanations, etc. in the comment section at the bottom of this page.

Excerpts are most of the time used as a Post summary. By default, excerpts in WordPress are only available for Posts. For most WordPress websites this will be enough as Pages are generally used for once-off content that is mostly not shown under the latest site content. Pages are, however, often included in the site’s search section, where a nice formatted (or custom) excerpt will fit in better with the rest of the site.

Activating excerpts for Pages

To activate excerpts for Pages in WordPress, the following function code needs to be added to the (child) theme’s functions.php file:

add_post_type_support( 'page', 'excerpt' );

This code will modify the default WordPress content type ‘Page’ to add support for excerpts. Once the functions.php is updated, new and existing Pages will show an excerpt meta box.

Excerpt for Pages are activated

If this box is left empty, WordPress will still generate its own excerpt based on the first text in the content section. By adding a custom excerpt to this section, WordPress will use that one in stead.

Using WordPress Page excerpts

Adding custom excerpts to Pages will often be enough for WordPress to automatically start using them in the default areas of rest of the site. For WordPress websites that makes frequent use of Pages, developers might want to use Page excerpts in their content.

The default PHP code for calling Page excerpts in WordPress is exactly the same as for calling excerpts for Post:

<?php echo get_the_excerpt(); ?>
About the author
Renier busies himself with improving his English writing, creative web design and his websites, photoshopping, micro-electronics, multiple genres of music, superhero movies and badass series.
Behind the Scenes is a free, informative website. If you find value in any of our content, please consider making a donation to our cause.
Donate via PayPal

Save, share & Disqus

Use the buttons below, on the left or the bottom of this page to share this post. Your comment is important, but don't be a knob. Keep it constructive and polite.

Comment via Disqus

Disqus is a worldwide comment hosting service for web sites and online communities. This secure platform ensures a pleasant commenting environment which is manageable from one account. Use the Login button to sign up.

More website development related posts

Get WP Toolset – for custom WordPress development without programming
Get WP Toolset – for custom WordPress development without programming
19 August 2019
Ad: Extend the functionality of WordPress with regards to its ability to store data and publish it on your website. More…
Using the Media Library Assistant plugin for WP
Using the Media Library Assistant plugin for WP
5 January 2019
WordPress websites with a large amount of Media content can become overwhelming to manage. With expanding libraries, images and other media can start to disappear in a sea of files which can make finding them very difficult. With the Media Library Assistant plugin for WordPress, searching and organising Media files becomes a breeze. More…
Disabling the Gutenberg Editor in WordPress 5
Disabling the Gutenberg Editor in WordPress 5
9 December 2018
Most WordPress users are probably happy with regular updates on their favourite content management website software, but for me, a striking difference starting at WordPress 5 was the Gutenberg Editor instead of the, now, Classic Editor. Without going into to much of a discussion, this post will show how disable the Gutenberg Editor. More…
Creating custom social media share buttons for posts
Creating custom social media share buttons for posts
27 October 2017 | Updated 19 March 2019
Website developers might find it necessary to have custom social share buttons at the top/bottom of their web pages. Custom buttons allow better integration with the rest of a website’s style and create a more unique look. More control over where these buttons appear on pages might also be beneficial. More…