» » How to create a RSS feed for Custom Post Types in WordPress

How to create a RSS feed for Custom Post Types in WordPress

posted in: Wordpress Tips | 0

How to create a RSS feed for Custom Post Types in WordPress

How to create a RSS feed for Custom Post Types in WordPress
How to create a RSS feed for Custom Post Types in WordPress

WordPress has a default feed that looks something like this – http://www.yoursite.co.za/feed/ and this feed serves any posts you make. But for developers that prefer to make use of custom post types, it becomes a whole new ballgame.  And that is exactly what happened to me.  I am busy creating a site www.careerexpress.co.za where I make use of custom post types for portfolios as well as open positions or opportunities. Off course I would like to give my prospective clients the ability to subscribe to the new portfolios and positions as the get added to the site. After a lot of trial and error I made my first successful RSS feed for Custom Post Types in WordPress. Step 1 – Determine the link to the Custom Post Type In my case the Custom Post Type (always use the slug and not the name) is “openposition”. Step 2 – Create the Custom Post Type RSS Feed URL If you want a RSS feed directly for the Custom Post Type you will create the following link. http://www.yoursite.co.za/feed/?post_type=yourcustomposttype For my site the link will look like this: http://www.careerexpress.co.za/feed/?post_type=openposition You can add this feed either to Feedburner or FeedBlitz (which by the way allows you to earn revenue from your feeds).  Or you can add it to your RSS Feed widget in WordPress. Usually when we create Custom Post Types, we have Taxonomies going with each Custom Post Type with Taxonomy Categories.  To add a taxonomy to your feed do the following  (please note the difference in the URL): Step 1 – Determine the full URL to the Taxonomy and Category The URL should look something like this: http://www.yoursite.co.za/taxonomy/category/ For my site the link will look like this: http://www.careerexpress.co.za/openpositions/freelancing/ Step 2 – Create the Custom Post Type RSS Feed with Taxonomy Add the following to your Custom Post Type and Taxonomy URL: feed/?post_type=taxonomy&taxonomycategory=category Your feed should now look something like this: http://www.yoursite.co.za/taxonomy/taxonomycategory/feed/?post_type=taxonomy&taxonomycategory=category My site has a taxonomy ‘openpositions’ and under this it has different categories such as ‘accounting’ and ‘freelancing’.  In this case I am going to use ‘freelancing’ as the category. This is what my RSS feed for my Custom Post Type with Taxonomy and Category looks like. http://www.careerexpress.co.za/openpositions/freelancing/feed/?post_type=openposition&openpositions=freelancing You can add this feed either to Feedburner or FeedBlitz (which by the way allows you to earn revenue from your feeds).  Or you can add it to your RSS Feed widget in WordPress.