Skip to content

Instantly share code, notes, and snippets.

@2aces
Created February 17, 2017 13:39
Show Gist options
  • Save 2aces/9ad979b2c0f6870f6f0400de94479fda to your computer and use it in GitHub Desktop.
Save 2aces/9ad979b2c0f6870f6f0400de94479fda to your computer and use it in GitHub Desktop.
Use this code snippet on functions.php file of a theme to add pages to a WordPress RSS feed.
/**
* 2a_feed_request function.
* adds any post type to RSS Feeds. In this example, we use 'post' and 'page' post types
*
* @access public
* @param mixed $qv
* @return array $qv filter $qv variable
*/
function 2a_feed_request($qv) {
if ( isset( $qv['feed'] ) && !isset( $qv['post_type'] ) ) {
$qv['post_type'] = array('post', 'page' );
// we could add registered custom post types as well, e.g. product or video
// $qv['post_type'] = array( 'post', 'page', 'product', 'video' );
}
return $qv;
}
add_filter('request', '2a_feed_request');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment