List all custom post type posts from a given category?

What about doing a tax_query? $args = array( ‘post_type’ => ‘myposttype’, ‘tax_query’=> array(         ‘taxonomy’ => ‘myposttype_categories’,         ‘terms’ => array(‘foo’),         ‘field’ => ‘slug’,     ) ); $loop = new WP_Query( $args ); var_dump($loop); Facepalm question, you are sure that these taxonomies/post types exist and that there are posts filed under them? Update The query seems to work … Read more

tax_query: What to pass when I want to have all terms?

Simply omit (or not add) tax_query part of arguments. $args = array( ‘post_type’ => ‘wr_event’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘event_date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => $order, ‘meta_value’ => $yesterday, ‘meta_compare’ => $compare, ); if ( ! is_null($cat) ) $args[‘tax_query’] =array( array( ‘taxonomy’ => ‘event_type’, ‘field’ => ‘slug’, ‘terms’ => $cat, ‘operator’ => ‘IN’ ), … Read more

Get Term names from WP Term Object

Here’s an alternative using the handy wp_list_pluck(): $terms = get_terms(array( ‘taxonomy’ => ‘category’, ‘hide_empty’ => false, )); $slugs = wp_list_pluck( $terms, ‘slug’ ); $names = wp_list_pluck( $terms, ‘name’ ); where we pluck out the wanted field into an array.

Alphabetical order in taxonomy.php

The main query is generated before the template is loaded, the results of the main query are how WordPress knows what template to load. If you want to alter query parameters of the main query to change things like orderby, you should add a function hooked to pre_get_posts. The argument passed to the function contains … Read more

Getting WordPress custom taxonomy/category?

I think you are getting confused by terminology here. Category is a taxonomy. Specific categories you create are terms. our_gallery is taxonomy. Landscapes is term. our_gallery is not category. It is its own taxonomy and has nothing to do with category taxonomy. get_the_category() function explicitly fetches terms of category taxonomy. To get terms of our_gallery … Read more