我正在为WordPress 3.5开发一个插件。我的博客的默认标题是“测试”。以下是我的插件的一些代码:
add_filter(\'wp_title\', \'my_replace_title\');
function my_replace_title(){
return get_option(\'my_site_title\');
}
新标题是“我的网站标题”。但结果是:“我的网站标题测试”
如何用新标题替换旧标题?
我正在为WordPress 3.5开发一个插件。我的博客的默认标题是“测试”。以下是我的插件的一些代码:
add_filter(\'wp_title\', \'my_replace_title\');
function my_replace_title(){
return get_option(\'my_site_title\');
}
新标题是“我的网站标题”。但结果是:“我的网站标题测试”
如何用新标题替换旧标题?
请尝试此代码,希望它能解决您的问题。
add_filter( \'wp_title\', \'theme_custom_title\', 20 ); function theme_custom_title $title ) { return str_replace(\'your old title\', \'your New title\', $title); }
// changes the "Enter title here" to "Enter some New title" add_filter(\'gettext\', \'custom_rewrites\', 10, 4);
function custom_rewrites($translation, $text, $domain) { global $post; $translations = &get_translations_for_domain($domain); $translation_array = array(); switch ($post->post_type) { case \'videofaqs\': $translation_array = array( \'Enter title here\' => \'Enter Video question here\' ); break; } if (array_key_exists($text, $translation_array)) { return $translations->translate($translation_array[$text]); } return $translation; }
以下代码块给出了一个累积结果:foreach($sections as $section) { $content_post = get_post($section->ID); $content = $content_post->post_content; $content = apply_filters(\'the_content\', $content); echo $content; } 如果我抓住了$con