开发者

wp_head remove_action not working in WP3.0

开发者 https://www.devze.com 2023-01-03 22:33 出处:网络
I have used the remove_action function in Wordpress before to remove junk from theinjected by wp_head but it seems that with version 3.0 开发者_如何学JAVAsome tags aren\'t being removed like the one b

I have used the remove_action function in Wordpress before to remove junk from the injected by wp_head but it seems that with version 3.0 开发者_如何学JAVAsome tags aren't being removed like the one below:

remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );

This should remove the prev link tag but it isn't. Anybody knows the reason?


Thanks to TheDeadMedic I found the solution in "wp-includes/default-filters.php". The following removes the next and prev links from wp_head:

remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );

This is the full script for removing all "unnecessary" meta tags from the <head>:

//remove_action( 'wp_head',             'wp_enqueue_scripts',            1     );
remove_action( 'wp_head',             'feed_links',                    2     );
remove_action( 'wp_head',             'feed_links_extra',              3     );
remove_action( 'wp_head',             'rsd_link'                             );
remove_action( 'wp_head',             'wlwmanifest_link'                     );
remove_action( 'wp_head',             'index_rel_link'                       );
remove_action( 'wp_head',             'parent_post_rel_link',          10, 0 );
remove_action( 'wp_head',             'start_post_rel_link',           10, 0 );
remove_action( 'wp_head',             'adjacent_posts_rel_link_wp_head', 10, 0 );
remove_action( 'wp_head',             'locale_stylesheet'                    );
remove_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 );
//remove_action( 'wp_head',             'noindex',                       1     );
remove_action( 'wp_head',             'wp_print_styles',               8     );
remove_action( 'wp_head',             'wp_print_head_scripts',         9     );
remove_action( 'wp_head',             'wp_generator'                         );
//remove_action( 'wp_head',             'rel_canonical'                        );
remove_action( 'wp_footer',           'wp_print_footer_scripts'              );
remove_action( 'wp_head',             'wp_shortlink_wp_head',          10, 0 );
remove_action( 'template_redirect',   'wp_shortlink_header',           11, 0 );

add_action('widgets_init', 'my_remove_recent_comments_style');
function my_remove_recent_comments_style() {
    global $wp_widget_factory;
    remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style'));
}
0

精彩评论

暂无评论...
验证码 换一张
取 消