Last active
December 19, 2015 18:19
-
-
Save dionysia/5997685 to your computer and use it in GitHub Desktop.
From Steve Zehngut http://zeek.com/add_feed/
This file contains hidden or 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
<!-- I discussed this function during the lightning round at WordCamp San Diego 2013. | |
add_feed() adds a custom feed to your WordPress site. I discovered this function recently when I needed to create a feed that | |
uses a custom query. Specifically, a client needed a feed that pulled together content in a single category from multiple | |
custom post types. The default WordPress category feeds will not pull content from multiple custom post types. The code below | |
can be dropped into functions.php in your theme folder or it could be rolled into a plugin. --> | |
add_feed( 'games' , 'make_games_feed' ); | |
function make_games_feed(){ | |
$args = array( | |
'post_type' => array('post','project'), | |
'cat' => get_cat_id('games') | |
); | |
query_posts($args); | |
include_once(ABSPATH . 'wp-includes/feed-rss2.php'); | |
wp_reset_query(); | |
} | |
<!-- After this code is added to your site, you must flush the rewrite rules to get it to take effect. A quick way to do this | |
is to go to SETTINGS -> PERMALINKS and click SAVE CHANGES. You don’t have to actually make a change --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment