更新日期:2014-08-13

利用 wp_head 可以將你需要的文件訊息輸出在 head 標記裡面,像是放 css 的 style、meta 等等。
例如這樣子:

<meta name=”keywords” content=”” />
<meta name=”description” content=”” />
<meta http-equiv=”X-UA-Compatible” content=”IE=7″ />
<link rel=”stylesheet” type=”text/css” href=”” />
<link rel=”shortcut icon” type=”image/ico” href=””>

若是你想新增一個 meta,你可以這樣子寫:

[php]
function add_my_meta(){
echo ‘<meta property="og:image" content="/image/xxx.jpg" />’ ;
}
add_action( ‘wp_head’, ‘add_my_meta’ , 10 );
[/php]

 

不過有些內建的輸出沒什麼用處,因此我們也可以移除,例如版本號碼:

<meta name=”generator” content=”WordPress 3.9.2″ />

移除的語法:

[php]
remove_action(‘wp_head’, ‘wp_generator’);
[/php]