# カスタム分類のラベルをwp_titleから削除

- リンク: https://torounit.com/blog/%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e5%88%86%e9%a1%9e%e3%81%ae%e3%83%a9%e3%83%99%e3%83%ab%e3%82%92wp_title%e3%81%8b%e3%82%89%e5%89%8a%e9%99%a4/
- 公開日: 2011-01-04T13:29:28+09:00
- 作成者: Toro\_Unit

カスタム分類のラベルが、wp_titleから出力されてしまうのを避けたかったのですが、プラグ
インなどを見つけられなかったので自作します。
 wp-include内のgeneral-template.php
からwp_titleのソースを失敬して、必要なところだけを書き換えてfilterにかけているだけ
ですが・・・・・。

functions.phpにでも書いて頂ければ動作します。
 [php] add_filter( ‘wp_title’, ‘fix_wp_title’,
10, 3 ); function fix_wp_title($title, $sep, $seplocation){ global $wp_query; if(
is_tax() ) { $term = $wp_query->get_queried_object(); $term = $term->name; $title
=$term; $t_sep = ‘%WP_TITILE_SEP%’; // Temporary separator, for accurate flipping,
if necessary

 $prefix = ”;
 if ( !empty($title) ) $prefix = " $sep "; if ( ‘right’ == $seplocation){
$title_array = explode( $t_sep, $title ); $title_array = array_reverse( $title_array);
$title = implode( " $sep ", $title_array ) . $prefix; } else { $title_array = explode(
$t_sep, $title ); $title = $prefix . implode( " $sep ", $title_array ); } } return
$title; }

[/php]
 一応WordPress3.0での動作は確認してあります。3.1でもたぶん動くと思いますけど・・・
