2011-09-08 35 views
4

我需要更改或使用插件
例如<title> My old title </title> =><title> New title </title>如何使用plugin,add_filter在wordpress中刪除或更改<title>標籤?

刪除<title>標籤在WordPress我嘗試

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

add_filter('wp_head','plugin_title'); 

//但它不工作。任何想法 ?

+0

可能重複的具體實施方法來解析用PHP HTML(http://stackoverflow.com/questions/3577641/best-methods-to-parse-html-與-php) – ajreal

+1

不是真的,這是Wordpress特定的。 – cmbuckley

+0

@cbuckley只要與HTML解析相關,是不是很難轉換它DomDocument – ajreal

回答

8

嘗試使用wp_title鉤的

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

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