Warning: The magic method InvisibleReCaptcha\MchLib\Plugin\MchBasePublicPlugin::__wakeup() must have public visibility in /home/twotone/twotone.me/public_html/wp-content/plugins/invisible-recaptcha/includes/plugin/MchBasePublicPlugin.php on line 37
WordPressのRSSにカスタム投稿を追加する方法 | web関連 | 二色人日記。
web関連

WordPressのRSSにカスタム投稿を追加する方法

WordPressのRSSにカスタム投稿を追加する方法

基本WordpressのRSSは「投稿」しか出力できないのだが、カスタム投稿も含んだRSSを取得したいときのメモ

RSSにカスタム投稿を追加する

functions.phpに以下の記述を入れます。

function myfeed_request($qv) {
if (isset($qv['feed']) && !isset($qv['post_type']))
$qv['post_type'] = array('post','カスタム投稿のスラッグ','カスタム投稿のスラッグ');
return $qv;
}
add_filter('request', 'myfeed_request');

カスタム投稿単体のRSSを取得する方法

ちなみにカスタム投稿単体のRSSを取得する時は、2パターンある。

http://sample.com/diary/feed/

か

http://sample.com/feed/?post_type=diary
あまり、クライアント案件だと使う機会がないけど、ブログ村とかブログランキングとかにカスタム投稿も含んだRSS登録する際に使える