Skip to content

Instantly share code, notes, and snippets.

@dboutote
Last active February 23, 2016 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dboutote/e96e8c062008ff84a3f0 to your computer and use it in GitHub Desktop.
Save dboutote/e96e8c062008ff84a3f0 to your computer and use it in GitHub Desktop.
Limit a WordPress feed to one post type.
<?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