Help us understand the problem. What is going on with this article?

WordPress: feedにカスタム投稿タイプを追加する【functions.php】

More than 5 years have passed since last update.

★のとこにfeedに追加したいカスタム投稿タイプを追加する

functions.php
/**
 * feedにカスタム投稿タイプを追加する
 */
add_filter('pre_get_posts', 'add_custom_post_type_feed');

function add_custom_post_type_feed($query)
{
  if (is_feed())
  {
    $post_type = $query->get('post_type');
    if (empty($post_type))
    {
      $query->set('post_type', array('post', 'hoge1-posts', 'hoge2-posts', 'note-posts')); // ★
    }
    return $query;
  }
}
akey
Designer + Front-End Developer
http://chocolateboard.net
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away