João Paulo Cercal

Staff Security Engineer at LastPass

  • PHP

Excerpts on WordPress 3.0+ pages

  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn

Read this article in

If you’ve ever needed to add excerpts to pages in WordPress 3.0+, you can be happy because the tip is very simple. Just add the following code to a file that wordpress loads automatically.

1
2
3
4
5
6
<?php
/**
 * @param string $post_type
 * @param string|array $supports
 */
add_post_type_support('search', 'excerpt');

Usually the code above is placed in an “init” action hook.

This will enable a new field in the administration panel, letting you add an excerpt to your pages.

In the case above, we’re adding the “excerpt” functionality to the “page” post type.

Visit the official WordPress Documentation and also the official documentation for this function for more details.