Dar*_*cyk 4 php wordpress plugins title add-filter
我需要<title>使用插件更改或删除wordpress 中的标签,
例如<title> My old title </title>=><title> New title </title>
我试试看
function plugin_title($content){
$content=str_replace('My old title','New title',$content);
return $content;
}
add_filter('wp_head','plugin_title');
Run Code Online (Sandbox Code Playgroud)
//但它不起作用.任何的想法 ?
尝试使用wp_title钩子
add_filter( 'wp_title', 'custom_title', 20 );
function custom_title( $title ) {
return str_replace('My old title', 'New title', $title);
}
Run Code Online (Sandbox Code Playgroud)