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
Top 10 Must Have Code Snippets to Supercharge Your WordPress Site
Ten essential code snippets that you can add to your functions.php file to enhance your WordPress site
Continue Reading Top 10 Must Have Code Snippets to Supercharge Your WordPress Site
Understanding the WordPress Query Loop Block: What It Is and How to Use It
The Query Loop Block is a powerful feature in WordPress that allows users to display lists of posts or pages dynamically.
Continue Reading Understanding the WordPress Query Loop Block: What It Is and How to Use It
Top 50 WordPress Blogs to market your WordPress product (2024 edition)
Discover the top 50 WordPress blogs to market your WordPress product in 2024. Learn effective strategies and stay tuned for more tips on boosting your plugin, theme, or tool’s visibility.
Continue Reading Top 50 WordPress Blogs to market your WordPress product (2024 edition)