我有一个wordpress网站,并使用此网址生成一位作者帖子的供稿:
http://www.my-awesome-site.com/author/joe/feed/
此Feed的自动生成的标题是“我的真棒网站>> Joe”
现在我想弄清楚如何将饲料标题更改为“乔史密斯真棒的智慧之词”。
我无法弄清楚Feed标题的生成位置,以及我可能用来过滤它的钩子。有什么想法吗?
编辑:哇这真是一种痛苦。没有意识到WP缓存了feed。我尝试了很多方法,但最后我只是破解了核心,将feed-rss.php,feed-rss2.php,feed-atom.php和feed-rdf.php中的标题标签更改为<title><?php
if (is_author('joe')) {
echo "Joe Smith's Awesome Words of Wisdom";
} else {
bloginfo_rss('name'); wp_title_rss();
}
?></title>
更好的建议仍然受到欢迎。
答案 0 :(得分:0)
我知道这是一个老问题,但我一直在寻找不使用插件的同类产品。 WordPress有两个过滤器供您使用:wp_title
和document_title_parts
:
方法1:使用wp_title
:
请注意,此方法仍会将网站说明附加在<title>
标记的末尾。
function custom_wp_title( $title, $sep ) {
if (is_author()) {
$author = array(
'user_firstname' => get_the_author_meta('user_firstname'),
'user_lastname' => get_the_author_meta('user_lastname')
);
$title = $author['user_firstname'] . ' ' . $author['user_lastname'] . ' Awesome Words of Wisdom.';
}
return $title;
}
add_filter( 'wp_title', 'custom_wp_title', 100, 2 );
方法2:使用document_title_parts
:
function custom_wp_title($title){
if(is_author()){
$author = array(
'user_firstname' => get_the_author_meta('user_firstname'),
'user_lastname' => get_the_author_meta('user_lastname')
);
$title['title'] = $author['user_firstname'] . ' ' . $author['user_lastname'] . ' Awesome Words of Wisdom.';
/* Uncomment this if you
** want to remove the site
** description at the end of the title:
$title['site'] = '';
**
**/
}
return $title;
}
add_filter('document_title_parts', 'custom_wp_title', 10);
答案 1 :(得分:-1)
您可以使用wordpress插件:
http://wordpress.org/extend/plugins/all-in-one-seo-pack/
这允许您更改所有与SEO相关的属性(元标记,描述,标题等...)
在选项中,有一个部分允许您更改特定页面和帖子类型的标题。