フィードカスタマイズ

  • Updated: 2023.05.30
  • Published: 2021.08.12
  • 701views
  • RSS
  • WordPress
  • フィード

フィードにカスタム投稿タイプの更新を含める

デフォルトではフィードにはカスタム投稿タイプは表示されないので下記を追加します。

/*--------------------------------------------------------
フィードにカスタム投稿タイプの更新を含める
--------------------------------------------------------*/
function mysite_feed_request($vars) {
	if ( isset($vars['feed']) && !isset($vars['post_type']) ){
		$vars['post_type'][] = '【投稿タイプ1】';
		$vars['post_type'][] = '【投稿タイプ2】';
	}
	return $vars;
}
add_filter( 'request', 'mysite_feed_request' );

フィードのauthorを変更

dc:creatorに表示される内容はログインのときのIDと同じであるため変更する必要があります。authorの名前をサイトの名前 get_bloginfo( ‘name’ )に変更

/*--------------------------------------------------------
//feedのauthor名を変更
--------------------------------------------------------*/
function delete_feed_author($author) {
    if(is_feed()){
        $author = get_bloginfo( 'name' ) ;
    }
    return $author;
}
add_filter( 'the_author', 'delete_feed_author');

フィードのauthorリンクを変更

authorのリンクが表示される場合、ユーザーの名前が表示されるためログインIDが分かってしまいます。authorのURLをサイトのURL get_bloginfo( ‘url’ )に変更

/*--------------------------------------------------------
//feedのauthorリンクを変更
--------------------------------------------------------*/
function delete_feed_author_url( $author_meta, $user_id ) {
    if(is_feed()){
        $author_meta = get_bloginfo( 'url' ) ;
    }
    return $author_meta;
}
add_filter( 'the_author_url', 'delete_feed_author_url');

関連記事

人気の投稿

最新の投稿

タグ

月別アーカイブ

Contact

WEB制作の依頼など気軽にお問い合わせください。

お問い合わせ