Adding Excerpts to Pages in WordPress

Being able to display post excerpt is a very useful feature in WordPress. This can also be used to display dynamic content on meta tag for better SEO purpose. On this site, I am also using the excerpt to display the summary of the articles. Specially on the archive pages. Interestingly, there are no excerpt feature for "Pages". However, with little effort we can easily add excerpt feature for pages. In this post, I will show you how to enable post excerpt for Pages. So, here we go.
function add_page_excerpt() {
   add_post_type_support('page','excerpt'); }
Simply copy and paste this snippet on your theme's functions.php file and update the page. This should enable the "excerpt" box for your Pages which you can use to write custom page summary. Once you are done, you can easily call "the_excerpt" function on your sit'e meta tags for enhanced SEO. Now, if you take a look at the function carefully. You can see that I used "add_post_type_support" function to enable excerpt for pages and initialized the function with an "add_action" hook. I already wrote an article on how to define the length of the excerpt which you may find to be useful and get creative with that.


Commenting is disabled.