Loading...
Home Picture
Code

Function to Change Remove Excess Header Tags from Posts/Pages

Scroll Down

/**
* code #12 - remove header meta tags from blog posts and pages.
* feel free to customize the options to suit your needs.
* source - http://wordpress.stackexchange.com/a/1569/8922
*/
function remove_default_post_metatags() {
remove_meta_box('postcustom','post','normal');
remove_meta_box('postexcerpt','post','normal');
remove_meta_box('commentstatusdiv','post','normal');
remove_meta_box('trackbacksdiv','post','normal');
remove_meta_box('slugdiv','post','normal');
remove_meta_box('authordiv','post','normal');
}
add_action('admin_menu','remove_default_post_metatags');

function remove_default_page_metatags() {
remove_meta_box('postcustom','page','normal');
remove_meta_box('postexcerpt','page','normal');
remove_meta_box('commentstatusdiv','page','normal');
remove_meta_box('trackbacksdiv','page','normal');
remove_meta_box('slugdiv','page','normal');
remove_meta_box('authordiv','page','normal');
}
add_action('admin_menu','remove_default_page_metatags');

One of the code snippets I mentioned earlier is used to remove unwanted tags in the document header. This is similar except we’re targeting meta tags which display on posts and pages. These tags are often just taking up space and do not provide much real valuable information to search crawlers. But just as before, feel free to comment out or remove lines of code for testing which meta tags should stay and which need to go.