How to change the title of a Wordpress author archive feed?
I have a wordpress site and have used this URL to generate a feed of one author's posts:
http://www.my-awesome-site.com/author/joe/feed/
The automatically generated title of this feed is "My Awesome Site >> Joe"
Now I'm trying to figure out how to change the feed title to something like "Joe Smith's Awesome Words of Wisdom."
I can't quite figure out where the feed title is generated, and what hook i might use to filter it. Any thoughts?
Edit: Wow this was a pain. Didn't realize for a while that WP caches feeds. I tried a number of approaches, but in开发者_运维知识库 the end I just hacked core, changing the title tag in feed-rss.php, feed-rss2.php, feed-atom.php, and feed-rdf.php to
<title><?php
if (is_author('joe')) {
echo "Joe Smith's Awesome Words of Wisdom";
} else {
bloginfo_rss('name'); wp_title_rss();
}
?></title>
Better suggestions still welcome.
I know this is an old question but I was looking for the same kind of thing without using a plugin. Wordpress has two filters for you to use: wp_title
and document_title_parts
:
METHOD 1: Using wp_title
:
Note that this method will still append the site description at the end of the <title>
tag.
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 );
METHOD 2: Using 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);
You can use the wordpress plugin:
http://wordpress.org/extend/plugins/all-in-one-seo-pack/
This allows you to change all SEO related properties (meta-tags, descriptions, titles etc...)
In the options there is a section that allows you to change titles for specific page and post types.
精彩评论