wordpress去掉版本信息,wordpress 精简优化 wp_head

admin123 2019-2-15 4227

wordpress去掉版本信息,wordpress  精简优化 wp_head

注明,如果theme里面有functions.php就以那个为准修改。

1. wordpress  head meta头部去掉admin bar css link

方法1. 注释掉

Enter this code into your current theme’s functions.php file to disable the admin bar:

找到function hide_admin_bar(){ return false; }

add_filter( 'show_admin_bar', 'hide_admin_bar' );

方法2. The third option includes copying and pasting the php snippet below and inserting it into your functions.php file.

  Enter this code into your current theme’s functions.php file to disable the admin bar:

add_filter( 'show_admin_bar', '__return_false' );

 

2. How to Remove link rel=’prev’ and link rel=’next’ from WordPress Head (in WP 3.0+)

In your WordPress template, you’ll find your functions.php file. Open that file and enter the following line.
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );

3. worldpress去掉版本信息,wordpress  精简优化 wp_head

就是在wodpress目录下注释掉wp-includes目录下的default-filters.php,大概在180多行:
//add_action( 'wp_head', 'feed_links', 2 ); 
//add_action( 'wp_head', 'feed_links_extra', 3 ); 
//add_action( 'wp_head', 'rsd_link' ); 
//add_action( 'wp_head', 'wlwmanifest_link' ); 
//add_action( 'wp_head', 'index_rel_link' ); 
//add_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); 
//add_action( 'wp_head', 'start_post_rel_link', 10, 0 ); 
//add_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); 
add_action( 'wp_head', 'locale_stylesheet' ); 
add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 ); 
add_action( 'wp_head', 'noindex', 1 ); 
add_action( 'wp_head', 'wp_print_styles', 8 ); 
add_action( 'wp_head', 'wp_print_head_scripts', 9 ); 
//add_action( 'wp_head', 'wp_generator' ); 
//add_action( 'wp_head', 'rel_canonical' ); 
add_action( 'wp_footer', 'wp_print_footer_scripts' ); 
//add_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); 
add_action( 'template_redirect', 'wp_shortlink_header', 11, 0 ); 
//add_action( 'wp_head', 'feed_links', 2 ); 
//add_action( 'wp_head', 'feed_links_extra', 3 ); 
//add_action( 'wp_head', 'rsd_link' ); 
//add_action( 'wp_head', 'wlwmanifest_link' ); 
//add_action( 'wp_head', 'index_rel_link' ); 
//add_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); 
//add_action( 'wp_head', 'start_post_rel_link', 10, 0 ); 
//add_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); 
add_action( 'wp_head', 'locale_stylesheet' ); 
add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 ); 
add_action( 'wp_head', 'noindex', 1 ); 
add_action( 'wp_head', 'wp_print_styles', 8 ); 
add_action( 'wp_head', 'wp_print_head_scripts', 9 ); 
//add_action( 'wp_head', 'wp_generator' ); 
//add_action( 'wp_head', 'rel_canonical' ); 
add_action( 'wp_footer', 'wp_print_footer_scripts' ); 
//add_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); 
add_action( 'template_redirect', 'wp_shortlink_header', 11, 0 );


最新回复 (0)
全部楼主
返回