Latest Tech and Tips

How to Add Custom Post Types to Your Main WordPress RSS Feed

0

Custom Post Types was just one of one of the most hyped function of WordPress 3.0. This function alone increased the perspective of WordPress use as a Content Management System (CMS). If you are making use of Custom Post Types, or thinking about custom post types, after that you might have need to add it right into your mainRSS Feed This alternative is not integrated by default since your main WordPress RSS feed just consists of “Posts” not also web pages, so custom post types are a long odds. In this write-up, we will certainly share how you can add Custom Post Types to your main WordPress RSS feeds.

You would certainly require to open your motif’s functions.php documents as well as add the adhering to code within the PHP markup:

 feature myfeed_request($ qv) {
if (isset($ qv['feed'])).
$ qv['post_type'] = get_post_types();.
return $qv;.
}
add_filter(' demand', 'myfeed_request');.

This code customizes the inquiry to maintain the default web content kind for article “post” generally RSS feed, as well as additionally including brand-new custom post types.

But suppose you have 5 custom post key ins your brand-new task, as well as you just desire to add 3 to the main RSS feed? Well that should not be any kind of trouble since we will certainly simply change the code a little to provide you the alternative to just consist of the ones that you desire.

 feature myfeed_request($ qv) {
if (isset($ qv['feed']) && & &! isset($ qv['post_type'])).
$ qv['post_type'] = variety(' post', 'tale', 'publications', 'motion pictures');.
return $qv;.
}
add_filter(' demand', 'myfeed_request');.

If you see in the code over, we merely included a variety to change the post_types that will certainly be displayed in the main RSS feed. We are revealing the default blog posts, tale, publications, as well as motion pictures.

Source: Core Trac Ticket #12943

.