How to Activate Excerpts for Pages in Wordpress Admin Panel
Posted on April 2, 2008Filed Under Tutorial
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. The Requests and Feedback section of the Wordpress forums can better fill you in on all of this.
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
View CodePHP | |
<?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
View CodePHP | |
<?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 } ?> | |
You can enter each function/hook combination into your theme’s functions.php file.
Hope someone finds this useful.
Comments
Leave a Reply

