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

Share
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
Learn Gutenberg block building – Create a block that renders an ACF field
With this tutorial, you’ll learn how to create a custom Gutenberg block that displays an ACF field on the front-end of your website.
Continue Reading Learn Gutenberg block building – Create a block that renders an ACF field
What is the theme.json in WordPress Full Site Editing?
Short introduction to the theme.json file that defines a WordPress full site editing theme. Includes useful resources to learn more!
Continue Reading What is the theme.json in WordPress Full Site Editing?
Creating a server side rendered Gutenberg block
Learn how to create your first ‘Hello World’ server side block. Adding dynamic content to your block theme with ease.
Continue Reading Creating a server side rendered Gutenberg block