Hiding taxonomies with no children WP_Query & tax_query

UPDATE! OK!!! Woooohooo! Found out what it was.. I should have been calling if have posts before the call for $tax->name; Here is my final, and working code! 🙂 <?php /**********************************************/ // CUSTOM WINE MENU SHORTCODE /**********************************************/ add_shortcode( ‘wine_list_per_cat’, ‘wine_list_per_cat’ ); function wine_list_per_cat($atts){ global $woocommerce_loop; extract(shortcode_atts(array( ‘cat’ => ”, // list of categories in the … Read more

Multiple filter conditions for WP_Query

Run first query las 10 posts, than use array_rand PHP function on posts array: $args = array( ‘posts_per_page’ => 10, ‘post__not_in’ =>array( $post->ID ), ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’ ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { if ( $query->post_count > 4 ) { $query->posts = array_rand( $query->posts, 4 ); … Read more