Php 如何删除或更改<;标题>;使用插件在wordpress中添加标签,添加过滤器?

Php 如何删除或更改<;标题>;使用插件在wordpress中添加标签,添加过滤器?,php,wordpress,plugins,title,add-filter,Php,Wordpress,Plugins,Title,Add Filter,我需要使用插件更改或删除wordpress中的标签 例如我的旧标题=>新标题 我试试看 function plugin_title($content){ $content=str_replace('My old title','New title',$content); return $content; } add_filter('wp_head','plugin_title'); //但它不起作用。有什么想法吗 尝试使用wp_标题挂钩 add_filter( 'wp_ti

我需要使用插件更改或删除wordpress中的
标签
例如
我的旧标题
=>
新标题

我试试看

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

add_filter('wp_head','plugin_title');

//但它不起作用。有什么想法吗

尝试使用wp_标题挂钩

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

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

可能的重复不是真的,这是Wordpress特有的。@cbuckley只要与HTML解析相关,就不难转换它DomDocument@ajreal:不。这与Wordpress如何实现插件有很大关系。