How to add an excerpt to pages and custom post types in WordPress

Expose the excerpt field for pages and custom post types with a small post-type support change.


Is an excerpt not showing for pages?

Excerpts are not supported by default for pages (it’s only a default feature for posts). You will not find excerpts under ‘screen options’ – you have to add support with code. To add support simply add the snippet below to your functions.php file.

add_action('after_setup_theme', function () {
  add_post_type_support('page', 'excerpt');
});

Add support for custom post types

When registering a custom post type, you can add the option to have excerpts with the ‘supports’ parameter. But if you want to add excerpt support for an existing custom post type and you don’t have access to the register script, use the same function as above but replacing ‘page’ with the slug name of your custom post type.

add_action('after_setup_theme', function () {
  add_post_type_support('your-custom-post-type', 'excerpt');
});

Displaying the excerpt

Support makes the excerpt field available; it does not automatically add it to the frontend. Use the Post Excerpt block in a template or Query Loop, or the appropriate excerpt function in a classic theme. Replace the example post-type slug with the registered name and confirm that its registration does not later remove excerpt support.

Good things, occasionally.

Fresh ideas, useful tools and better ways to build. Delivered when we have something worth sharing.