开发者

How remove or change <title> tag in wordpress using plugin , add_filter ?

开发者 https://www.devze.com 2023-04-03 17:44 出处:网络
I need change or remove 开发者_如何学Python<title> tag in wordpress using plugin for example <title> My old title </title> => <title> New title </title>

I need change or remove 开发者_如何学Python<title> tag in wordpress using plugin

for example <title> My old title </title> => <title> New title </title>

I try it

function plugin_title($content){
    $content=str_replace('My old title','New title',$content); 
    return $content;
}

add_filter('wp_head','plugin_title');

// but it doesn't work . Any idea ?


Try using the wp_title hook

add_filter( 'wp_title', 'custom_title', 20 );

function custom_title( $title ) {
    return str_replace('My old title', 'New title', $title); 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消