Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active Nov 22, 2022
Embed
What would you like to do?
add_filter( 'pre_get_posts', 'add_cpt_to_loop_and_feed' );
/**
* @author Brad Dalton
* @example http://wpsites.net/wordpress-tips/add-custom-post-type-to-rss-feed/
* @copyright 2014 WP Sites
*/
function add_cpt_to_loop_and_feed( $query ) {
if ( is_home() && $query->is_main_query() || is_feed() )
$query->set( 'post_type', array( 'post', 'your-cpt' ) );
return $query;
}
@sanderlt
Copy link

sanderlt commented Nov 11, 2020

thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment