Add CPT product to main blog feed
-
I tried different codes in my function.php, but i’m still unable to make this work. I switched the plugin on and off, also inserted the register code directly into my functions.php and removed it from the CPT plugin.
I tried with another CPT that are still in the CPT plugin, nothing works.I also added these two lines right after
register_post_type( 'produkt', $args );
in my functions.php:global $wp_query; $query = $wp_query;
These are some of the codes I tried:
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('prod'); $query->set( 'post_type', array_merge( array( 'post' ), $cptui_post_types ) ); } add_filter( 'pre_get_posts', 'my_cptui_add_post_types_to_rss' );
_________________________________-
function myfeed_request($qv) { if (isset($qv['feed']) && !isset($qv['post_type'])) $qv['post_type'] = array('post', 'prod'); return $qv; } add_filter('request', 'myfeed_request'); function prod_in_home_loop( $query ) { if ( is_home() && $query->is_main_query() ) $query->set( 'post_type', array( 'post', 'prod') ); return $query; } add_filter( 'pre_get_posts', 'prod_in_home_loop' );
_______________________
What am I missing here?
Thanks! Caroline
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Add CPT product to main blog feed’ is closed to new replies.