Skip to content

Instantly share code, notes, and snippets.

@dingo-d
Created April 3, 2016 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dingo-d/70db0b31d6d8d093a5c268a093e57fd9 to your computer and use it in GitHub Desktop.
Save dingo-d/70db0b31d6d8d093a5c268a093e57fd9 to your computer and use it in GitHub Desktop.
A code to make excerpts meta box show above the post content
<?php
add_action( 'admin_menu' , 'mytheme_remove_normal_excerpt' );
if (!function_exists('mytheme_remove_normal_excerpt')) {
function mytheme_remove_normal_excerpt() {
remove_meta_box( 'postexcerpt' , 'post' , 'normal' );
}
}
add_action( 'add_meta_boxes', 'mytheme_add_excerpt_meta_box' );
if (!function_exists('mytheme_add_excerpt_meta_box')) {
function mytheme_add_excerpt_meta_box( $post_type ) {
if ( in_array( $post_type, array( 'post', 'page' ) ) ) {
add_meta_box(
'mytheme_postexcerpt',
esc_html__( 'Excerpt', 'mytheme' ),
'post_excerpt_meta_box',
$post_type,
'after_title',
'high'
);
}
}
}
add_action( 'edit_form_after_title', 'mytheme_run_after_title_meta_boxes' );
if (!function_exists('mytheme_run_after_title_meta_boxes')) {
function mytheme_run_after_title_meta_boxes() {
global $post, $wp_meta_boxes;
do_meta_boxes( get_current_screen(), 'after_title', $post );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment