Created
April 3, 2016 18:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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