Created
February 17, 2017 13:39
-
-
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.
This file contains 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
/** | |
* 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