Creating a custom feed for categories that includes the first post’s featured image

First define a function to return the first post of a category by a given category ID ex: function get_category_post($cat_id){ $post_args = array( ‘numberposts’ => 1, ‘category’ => $cat_id, ‘fields’ => ‘ids’ ); $posts = get_posts($post_args); return $posts[0]; } Then, once you have that function you can use it like this: function outputXMLFeed() { echo … Read more

Get posts from 2 different categories

The first two methods aren’t working because the ‘cat=” and “category__and’ query variables are only for the standard post type (built in) Category taxonomy conditions. The 3rd method is nested in multiple foreach loops which could be the cause of the duplication. I think it will work like you want if you just remove both … Read more