Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dotherightthing/4515528bfb4a10751450442f0f5899a9 to your computer and use it in GitHub Desktop.
Save dotherightthing/4515528bfb4a10751450442f0f5899a9 to your computer and use it in GitHub Desktop.
[Move the excerpt meta box above the editor] #wordpress
/**
* Removes the regular excerpt box. We're not getting rid
* of it, we're just moving it above the wysiwyg editor
*
* @return null
*/
function oz_remove_normal_excerpt() {
remove_meta_box( 'postexcerpt' , 'post' , 'normal' );
}
add_action( 'admin_menu' , 'oz_remove_normal_excerpt' );
/**
* Add the excerpt meta box back in with a custom screen location
*
* @param string $post_type
* @return null
*/
function oz_add_excerpt_meta_box( $post_type ) {
if ( in_array( $post_type, array( 'post', 'page' ) ) ) {
add_meta_box(
'oz_postexcerpt',
__( 'Excerpt', 'thetab-theme' ),
'post_excerpt_meta_box',
$post_type,
'after_title',
'high'
);
}
}
add_action( 'add_meta_boxes', 'oz_add_excerpt_meta_box' );
/**
* You can't actually add meta boxes after the title by default in WP so
* we're being cheeky. We've registered our own meta box position
* `after_title` onto which we've regiestered our new meta boxes and
* are now calling them in the `edit_form_after_title` hook which is run
* after the post tile box is displayed.
*
* @return null
*/
function oz_run_after_title_meta_boxes() {
global $post, $wp_meta_boxes;
# Output the `below_title` meta boxes:
do_meta_boxes( get_current_screen(), 'after_title', $post );
}
add_action( 'edit_form_after_title', 'oz_run_after_title_meta_boxes' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment