以下代码加入functions.php里

// 头部冗余代码
remove_action( 'wp_head', 'wp_generator' );//移除WordPress版本
remove_action( 'wp_head', 'rsd_link' );//移除离线编辑器开放接口
remove_action( 'wp_head', 'wlwmanifest_link' );//移除离线编辑器开放接口
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );//上下文章的url
remove_action( 'wp_head', 'feed_links', 2 );//移除feed
remove_action( 'wp_head', 'feed_links_extra', 3 );//移除feed
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );//去除rel=shortlink 动态链接
remove_action( 'template_redirect', 'wp_shortlink_header', 11, 0 );//HTTP响应头中的 rel=shortlink 动态链接
//移除头部wp_json链接
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
//移除HTTP header 中的 wp-json link
remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 );

//禁用wordpress的文章嵌入功能
function disable_embeds_code_init() {
    // Remove the REST API endpoint.
    remove_action( 'rest_api_init', 'wp_oembed_register_route' );
    // Turn off oEmbed auto discovery.
    add_filter( 'embed_oembed_discover', '__return_false' );
    // Don't filter oEmbed results.
    remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
    // Remove oEmbed discovery links.
    remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
    // Remove oEmbed-specific JavaScript from the front-end and back-end.
    remove_action( 'wp_head', 'wp_oembed_add_host_js' );
    add_filter( 'tiny_mce_plugins', 'disable_embeds_tiny_mce_plugin' );
    // Remove all embeds rewrite rules.
    add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
    // Remove filter of the oEmbed result before any HTTP requests are made.
    remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );
  }
  add_action( 'init', 'disable_embeds_code_init', 9999 );
  function disable_embeds_tiny_mce_plugin($plugins) {
    return array_diff( $plugins, array('wpembed') );
  }
  function disable_embeds_rewrites ($rules) {
  foreach($rules as $rule => $rewrite) { 
    if(false !== strpos($rewrite, 'embed=true')) {
      unset($rules[$rule]);
    }  
  }
  return $rules;
  }
remove_action( 'admin_print_scripts' ,    'print_emoji_detection_script');
remove_action( 'admin_print_styles'  ,    'print_emoji_styles');
remove_action( 'wp_head'             ,    'print_emoji_detection_script',    7);
remove_action( 'wp_print_styles'     ,    'print_emoji_styles');
remove_filter( 'the_content_feed'    ,    'wp_staticize_emoji');
remove_filter( 'comment_text_rss'    ,    'wp_staticize_emoji');
remove_filter( 'wp_mail'             ,    'wp_staticize_emoji_for_email');