Skip to content

Instantly share code, notes, and snippets.

@cyberwani
Forked from eteubert/abstract-example.php
Created December 28, 2012 09:39
Show Gist options
  • Save cyberwani/4396428 to your computer and use it in GitHub Desktop.
Save cyberwani/4396428 to your computer and use it in GitHub Desktop.
<?php
$wp_meta_boxes[ 'post' ][ 'normal' ][ 'core' ][ 'post excerpt' ][ 'title' ] = 'Abstract';
$wp_meta_boxes[ 'post' ][ 'normal' ][ 'core' ][ 'post excerpt' ][ 'id' ] = 'postabstract';
<?php
/**
* Display post excerpt form fields.
*
* @since 2.6.0
*
* @param object $post
*/
function post_excerpt_meta_box($post) {
?>
<label class="screen-reader-text" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
<p><?php _e('Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="http://codex.wordpress.org/Excerpt" target="_blank">Learn more about manual excerpts.</a>'); ?></p>
<?php
}
<?php
function my_post_abstract_meta_box( $post ) {
?>
<label class="screen-reader-text" for="excerpt"><?php _e( 'Abstract' ) ?></label>
<textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
<p>
This is my custom text.
</p>
<?php
}
function customize_metaboxes( $post_type, $post ) {
global $wp_meta_boxes;
$wp_meta_boxes[ 'post' ][ 'normal' ][ 'core' ][ 'postexcerpt' ][ 'title' ] = 'Abstract';
$wp_meta_boxes[ 'post' ][ 'normal' ][ 'core' ][ 'postexcerpt' ][ 'id' ] = 'postabstract';
$wp_meta_boxes[ 'post' ][ 'normal' ][ 'core' ][ 'postexcerpt' ][ 'callback' ] = 'my_post_abstract_meta_box';
}
add_action( 'add_meta_boxes', 'customize_metaboxes', 10, 2 );
<?php
function customize_metaboxes( $post_type, $post ) {
global $wp_meta_boxes;
// inspect $wp_meta_boxes
echo "<pre>";
var_dump( $wp_meta_boxes );
echo "</pre>";
// customize ...
}
add_action( 'add_meta_boxes', 'customize_metaboxes', 10, 2 );
<?php
$wp_meta_boxes
[ posttype ] // dashboard, page, post, ...
[ column ] // normal, side
[ 'core' ]
[ box_handle ] // postexcerpt, trackbacksdiv, postcustom, commentstatusdiv,
// slugdiv, authordiv, submitdiv, formatdiv, categorydiv, tagsdiv-post_tag
[ box_attribute ] // id, title, callback, args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment