• Skip to main content
  • Skip to primary sidebar
  • Home
  • Contact
  • Blogging Advice
  • Technology
  • Business Blogging

Business Logs

Helping companies communicate better

WordPress Tip: Enable excerpts for static pages

We’re working on a site that lists the children of a static page and wanted to display descriptions for each one. Doing a custom WP_Query is pretty straightforward in accessing those subpages, but we don’t want to display the full content via the_content(). Built-in excerpts via the_excerpt() will suffice.

Problem is, WordPress doesn’t display the excerpt metabox for pages, unlike posts. This can be solved by adding the following code to your functions.php:

[php]function businesslogs_add_excerpt_box() {
add_meta_box(‘postexcerpt’, __(‘Excerpt’), ‘post_excerpt_meta_box’, ‘page’, ‘normal’, ‘core’);
}
add_action( ‘admin_menu’, ‘businesslogs_add_excerpt_box’ );[/php]

(Remember that it’s always a good idea to prefix your custom functions with a unique string.) Now go to the Page editor screen, pull down the Screen Options panel, and check Excerpt. Et voila!

About Lorraine Barte Nepomuceno

Primary Sidebar

Categories