如何更改Wordpress作者存档提要的标题?

问题描述 投票:0回答:2

我有一个wordpress网站,并使用此URL生成了一个作者帖子的提要:

http://www.my-awesome-site.com/author/joe/feed/

此提要的自动生成的标题是“我的真棒网站>> Joe”

现在,我试图弄清楚如何将提要标题更改为类似“乔·史密斯的真棒智慧语”。

我不太清楚提要标题是在哪里生成的,以及我可能用来过滤它的钩子。有什么想法吗?

编辑:哇,这很痛苦。一段时间没有意识到WP缓存提要。我尝试了多种方法,但最后我只是破解了内核,将feed-rss.php,feed-rss2.php,feed-atom.php和feed-rdf.php中的title标签更改为

<title><?php
    if (is_author('joe')) {
        echo "Joe Smith's Awesome Words of Wisdom";
    } else {
        bloginfo_rss('name'); wp_title_rss(); 
    }
?></title>

仍然欢迎更好的建议。

wordpress rss filter title archive
2个回答
0
投票

我知道这是一个老问题,但是我一直在寻找不使用插件的同类产品。 Wordpress有两个过滤器供您使用:wp_titledocument_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
投票

您可以使用wordpress插件:

http://wordpress.org/extend/plugins/all-in-one-seo-pack/

这使您可以更改所有与SEO相关的属性(元标记,描述,标题等...]

在选项中,有一个部分允许您更改特定页面和帖子类型的标题。

© www.soinside.com 2019 - 2024. All rights reserved.