• Resolved caroline

    (@makeupedia)


    Hi! I use this code to create a feed for my custom post type. It works fine. I want to add my CPT feed to the main RSS feed. How can I tweak the code to do this?

    Thank you!

    Caroline

    function my_cptui_add_post_types_to_rss( $query ) {
    // We do not want unintended consequences.
    if ( ! $query->is_feed() ) {
    return;
    }

    // Replace these slugs with the post types you want to include.
    $cptui_post_types = array(‘produkt’);

    $query->set(
    ‘post_type’,
    array_merge(
    array( ‘post’ ),
    $cptui_post_types
    )
    );
    }
    add_filter( ‘pre_get_posts’, ‘my_cptui_add_post_types_to_rss’ );

Viewing 1 replies (of 1 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Overall looks fine to me in terms of how the code should look. How many posts are you working with at the moment and how many from the custom post type? It’s possible that the dates are different enough that you’re not seeing both within the default 10 items for RSS feeds. Could be tested and confirmed how the feed is looking by publishing a new post in both, and then visiting https://www.MYSITE.com/feed

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Type feed to main RSS’ is closed to new replies.