Create a gist now

Instantly share code, notes, and snippets.

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