Query multiple taxonomy in Custom Post Type

There’s the “tax_query” argument available since the latest wp release: global $query_string; $args[‘tax_query’] = array( array( ‘taxonomy’ => ‘status’ ,’terms’ => array( ‘available’, ‘pending’ ) // change to “sold” for 2nd query ,’field’ => ‘slug’ ), ); $args[‘post_type’] = ‘listing’; parse_str( $query_string, $args ); $avail_n_pend = query_posts( $args ); if ( $avail_n_pend->have_posts() ) : while … Read more

On Taxonomy Template page, want to add Post_Type

You can use pre_get_posts filter hook to check if you are on the taxonomy page and if so just add your custom post type to the query something like this: function add_my_type( $query ) { if ( $query->is_tax(‘YOUR_TAXONOMY’) ) { $query->set( ‘post_type’, array(‘post’,’YOUR_CUSTOM_POST’) ); } } add_filter( ‘pre_get_posts’, ‘add_my_type’ );

get taxonomy terms for parent and child

You should have two foreach loops. One for getting parent taxonomy terms, and second for getting child taxonomy terms. In the second foreach you need to specify the parent taxonomy term ID which is $parent_term->term_id from the first foreach loop. foreach( get_terms( ‘products-category’, array( ‘hide_empty’ => false, ‘parent’ => 0 ) ) as $parent_term ) … Read more

How do I add a custom post type to the Featured Content in twenty fourteen theme?

The twentyfourteen_get_featured_posts filter: It took some digging, to figure out how the twentyfourteen_get_featured_posts filter is used in the TwentyFourteen theme 😉 The featured content is fetched with: $featured_posts = twentyfourteen_get_featured_posts(); but this function is only this single line: return apply_filters( ‘twentyfourteen_get_featured_posts’, array() ); so where’s the meat? We find it in the Featured_Content class, starting … Read more