Last active
February 23, 2016 20:28
-
-
Save dboutote/e96e8c062008ff84a3f0 to your computer and use it in GitHub Desktop.
Limit a WordPress feed to one post type.
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
<?php | |
function my_feed_filter($query) { | |
if ( $query->is_feed && 'cpt_shop' === $query->get('post_type') ) { | |
$query->set('order', 'asc'); | |
$query->set('meta_key', '_alt_title'); | |
$query->set('orderby', 'meta_value'); | |
}; | |
return $query; | |
}; | |
add_filter('pre_get_posts','my_feed_filter'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment