Last active
November 22, 2022 08:33
-
-
Save braddalton/e6a90f2b3623d212cb81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you very much!