I always wondered why wordpress allowed excerpts for posts and not for pages. A bit odd considering that both posts and pages are stored in the same database table and can have the same values stored for them. I have found a rather nice work around for this in 2.3.3 and then came…….. Wordpress 2.5!
I recently had a chance to upgrade one of the sites that I manage to the brand new Wordpress 2.5. I noticed right away that drastic changes had been made to the admin section – some for the better and some for the worse.
One thing I noticed immediately was that the Post and Page screens had been completely overhauled. This made me wonder whether or not my custom mf_add_excerpt_to_page() function still worked.
No dice.
Broken.
Luckily it took under 10 minutes to upgrade the function to work with two-point-five. For your viewing pleasure (drum roll please? ) here are both versions:
Wordpress 2.3
<?php
add_action( 'dbx_page_advanced', 'mf_add_excerpt_to_page' );
function mf_add_excerpt_to_page(){
global $post;
?>
<div class="dbx-b-ox-wrapper">
<fieldset id="postexcerpt" class="dbx-box">
<div class="dbx-h-andle-wrapper">
<h3 class="dbx-handle"><?php _e('Optional Excerpt') ?></h3>
</div>
<div class="dbx-c-ontent-wrapper">
<div class="dbx-content"><textarea rows="20" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea></div>
</div>
</fieldset>
</div>
<?php
}
?>
Wordpress 2.5
<?php
add_action('edit_page_form', 'mf_add_excerpt_to_page' );
function mf_add_excerpt_to_page(){
global $post;
?>
<div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt', 'post'); ?>">
<h3><?php _e('Excerpt') ?></h3>
<div class="inside"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea>
<p><?php _e('Excerpts are optional hand-crafted summaries of your content. You can <a href="http://codex.wordpress.org/Template_Tags/the_excerpt" target="_blank">use them in your template</a>'); ?></p>
</div>
</div>
<?php
}
?>
WordPress 2.9.1
These edits allow for drag and drop functionality in the WordPress Administration Panels.
add_action( 'admin_menu', 'mf_add_page_excerpt_box' );
function mf_add_page_excerpt_box() {
add_meta_box( 'mf_page_excerpt', __( 'Excerpt' ), 'mf_page_excerpt_box', 'page', 'normal', 'high' );
}
function mf_page_excerpt_box() {
global $post;
$message = __( 'Excerpts are optional hand-crafted summaries of your content. You can <a href="http://codex.wordpress.org/Template_Tags/the_excerpt" target="_blank">use them in your template</a>' );
print <<<EOF
<div class="inside">
<textarea rows="1" cols="40" name="excerpt" tabindex="3" id="excerpt">{$post->post_excerpt}</textarea>
<p>{$message}</p>
</div>
EOF;
}
You can enter each function/hook combination into your theme’s functions.php file.
One Step Beyond
Now that we have set up excerpts for out pages it might be a good time to make that box a little bit bigger… you know, the one where you type the excerpt into? You can add the following code to functions.php. Tested only in WordPress version 2.9.1
add_action( 'admin_head', 'mf_page_excerpt_css' );
function mf_page_excerpt_css() {
print '<style type="text/css">#excerpt{ height:10em; }</style>';
}
Hope someone finds this useful.


Hey,
your solution looks pretty simple, but I cannot find any hint, where to place the code! :-|
Cheers,
Sebastian
… oh – sorry – I was blind!
functions.php!
wow – it is so easy! Thank you … and sorry for more comments than necessary!
Thanks for the info!
Thanks. You really make it easy for me. Nice solution.
Works perfectly in 2.8.5. Thanks much!
Works perfectly in 2.8.6 as well!
As of WordPress 2.9.1 the function works beautifully. The only small issue I’m noticing is that while I’m able to drag and drop all other modules on my edit Page screen, I’m not able to drag and drop the Excerpt box. Thanks a ton for the code.
@Philip – Thanks for writing. I’ve updated this article with a new bit of code which allows for the drag and drop functionality to work. And Thanks to Mat and Jonah for verifying that the code works on earlier versions. This info is really helpful!
Wow, Michael. Thanks a ton for emailing me and whipping up that fix. You rock! It works wonderfully.
Hi Mike. Nice to see how that works. I’ve been using the page excerpt plug-in for this in the past- but it is nice to be able to enable it on a theme by theme basis.
@Philip – No problem! It’s about time that I’ve updated this page…
@Devin – I wrote this article about 20 months ago during my “I don’t use plugins… period!” period. I scoped out the plugin that you linked to and the code is almost identical save the
tabindexattributes on thetextarea…Extremely useful. Thanks Michael.
Hello! First of all.. thanks for this great plugin!
I wish to show in the front page all excerpts of pages, like a big resume of all site.
Maybe a way of get excerpts by ID, its possible?
Anyone have an idea?
Thanks