WordPress删除不必要的meta标签
WordPress默认情况下引用系统 wp_head()获得很多的meta标签,其中有一些不太必要,所以我们可以通过add_filter和 remove_action删除这些标签。
打开主题下的 functions.php文件,加入下面的内容:
add_filter('the_generator','wpbeginner_remove_version'); remove_action('wp_head','rsd_link'); remove_action('wp_head','wlwmanifest_link'); remove_action('wp_head','wp_generator'); remove_action('wp_head','start_post_rel_link'); remove_action('wp_head','index_rel_link'); remove_action('wp_head','parent_post_rel_link'); remove_action('wp_head','adjacent_posts_rel_link'); remove_action('wp_head','rel_canonical'); remove_action('wp_head','feed_links',2); remove_action('wp_head','feed_links_extra',3); remove_action('wp_head','wp_shortlink_wp_head',10,0);
再删除主题下的header.php如下的内容:
<linkrel="profile"href="http://gmpg.org/xfn/11"/> <linkrel="pingback"href="<?phpbloginfo('pingback_url');?>"/>
这样,这些不需要的meta标签就会从博客前台消失了。