functions.php最初に書いておきたいコード
<?php
// ヘッダーにある不要なタグを非表示
add_theme_support( ‘post-thumbnails’ );
remove_action( ‘wp_head’, ‘wp_generator’ );
remove_action( ‘wp_head’, ‘rsd_link’ );
remove_action( ‘wp_head’, ‘wp_generator’ );
remove_action( ‘wp_head’, ‘feed_links’, 2 );
remove_action( ‘wp_head’, ‘index_rel_link’ );
remove_action( ‘wp_head’, ‘wlwmanifest_link’ );
remove_action( ‘wp_head’, ‘feed_links_extra’, 3 );
remove_action( ‘wp_head’, ‘start_post_rel_link’, 10, 0 );
remove_action( ‘wp_head’, ‘parent_post_rel_link’, 10, 0 );
remove_action( ‘wp_head’, ‘adjacent_posts_rel_link’, 10, 0 );
remove_action( ‘wp_head’, ‘rest_output_link_wp_head’ ); //<link rel=’https://api.w.org/’ href=’http://example.com/wp-json/’ />
remove_action( ‘wp_head’, ‘wp_oembed_add_discovery_links’ ); //<link rel=”alternate” type=”application/json+oembed” href=”http://example.com/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fon-ze.com%2F” /><link rel=”alternate” type=”text/xml+oembed” href=”http://example.com/wp-json/oembed/1.0/embed?url=http%3A%2F%example.com%2F&format=xml” />
remove_action( ‘wp_head’, ‘wp_oembed_add_host_js’ ); //<script type=’text/javascript’ src=’http://example.com/wordpress/wp-includes/js/wp-embed.min.js’></script>
remove_action( ‘template_redirect’, ‘rest_output_link_header’, 11 ); //Link: <http://example.com/wp-json/>; rel=”https://api.w.org/”
//emoji 無効
function disable_emoji() {
remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
remove_action( ‘admin_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’ );
}
add_action( ‘init’, ‘disable_emoji’ );
//body_classにスラッグを追加
function pagename_class( $classes = ” ) {
if ( is_page() ) {
$page = get_post( get_the_ID() );
$classes[] = ‘page-‘ . $page->post_name;
if ( $page->post_parent ) {
$classes[] = ‘page-‘ . get_page_uri( $page->post_parent ) . ‘-child’;
}
}
return $classes;
}
add_filter( ‘body_class’, ‘pagename_class’ );
// アイキャッチ
function add_thumbnail_size() {
add_theme_support( ‘post-thumbnails’ );
set_post_thumbnail_size( 500, 500 );
add_image_size( ‘activity_single’, 450, 270, true );
add_image_size( ‘medium’, 240, 169, true );
add_image_size( ‘xsmall’, 230, 160, true );
add_image_size( ‘small’, 80, 80, true );
}
add_action( ‘after_setup_theme’, ‘add_thumbnail_size’ );
//WordPress同梱のjQueryを読み込ませない
function new_deregister_script() {
if ( !is_admin() ) {
wp_deregister_script( ‘jquery’ );
}
}
add_action( ‘init’, ‘new_deregister_script’ );
?>