CPT On Blog Page, Feed And CPT RSS Feed Links
-
I have searched and searched and just cannot seem to find an answer for this.
The goal is to display CPT on the blog and feed along with each CPT having its own RSS feed link.
The first code below will list the CPT on the blog, but not on the blogs RSS feed. However, it allows the CPT to have its own RSS feed link:
ie:
https://domain/feed?post_type=example
https://domain/feed?post_type=example-two// Adds Custom Post Type To Home And Feed function home_feed_loop( $query ) { if ( is_home() && $query->is_main_query() ) $query->set( 'post_type', array( 'post', 'example', 'example-two') ); return $query; } add_filter( 'pre_get_posts', 'home_feed_loop' );
The second code below allows the CPT on the front page and the blogs RSS feed. However, it removes the ability for the CPT to have its own RSS feed link:
ie:
https://domain/feed?post_type=example
https://domain/feed?post_type=example-two// Adds Custom Post Type To Home And Feed function home_feed_loop( $query ) { if ( ( is_home() && $query->is_main_query() ) || is_feed() ) $query->set( 'post_type', array( 'post', 'example', 'example-two') ); return $query; } add_filter( 'pre_get_posts', 'home_feed_loop' );
Where am I going wrong?
I would like to obtain all functionality. As in, have the CPT on the blog, in the blog feed and each CPT also have its own rss feed link.
- The topic ‘CPT On Blog Page, Feed And CPT RSS Feed Links’ is closed to new replies.