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

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');

Read more tutorials

Stay updated with the latest from WpBlockz

* indicates required