wordpress function.php

// 自動挿入されるpやbrタグを削除
remove_filter(‘the_content’, ‘wpautop’);

#アップデートのお知らせ隠す
add_filter( ‘pre_site_transient_update_core’, create_function( ‘$a’, “return null;” ) );

#管理者ヘッダー隠す
function my_function_admin_bar(){
return false;
}
add_filter( ‘show_admin_bar’ , ‘my_function_admin_bar’);

#ヘッダーの不要META類削除
remove_action(‘wp_head’, ‘index_rel_link’); //link rel=’index’ タグを削除
remove_action(‘wp_head’, ‘parent_post_rel_link’, 10);
remove_action(‘wp_head’, ‘start_post_rel_link’, 10); //link rel=’start’ タグを削除
remove_action(‘wp_head’, ‘adjacent_posts_rel_link’, 10); // Post Relational Links
remove_action(‘wp_head’, ‘rsd_link’); //Really Simple Discovery
remove_action(‘wp_head’, ‘wlwmanifest_link’); //Windows Live Writer
remove_action(‘wp_head’, ‘wp_generator’); //WordPress Generator
remove_action(‘wp_head’, ‘feed_links_extra’,3,0); //comment feed
#

//アイキャッチ画像を有効にする
add_theme_support(‘post-thumbnails’);

function post_ogp($id) {
$noImg = ‘ogp_default.jpg’;
//アイキャッチ画像を取得
$eyeImg = wp_get_attachment_image_src( get_post_thumbnail_id(), ‘thumbnail’);

if ($eyeImg){
//アイキャッチ画像があれば優先
echo $eyeImg[0];
} else {
//エントリーに属する画像を取得
$query = ‘post_parent=’ . $id . ‘&post_type=attachment&post_mime_type=image’;
$postImg = get_children($query);

if (!empty($postImg)){
//最初にアップロードされた画像IDを取得
$keys = array_keys($postImg);
$num = $keys[sizeOf($keys)-1];

//画像IDからサムネイルを取得
$thumb = wp_get_attachment_image_src($num, ‘thumbnail’);

echo clean_url($thumb[0]);
} else {
echo get_bloginfo(‘template_directory’) . ‘/’ . $noImg;
}
}
}