How can I write a WP_Query that is this specific?

The tax_query attribute is what you need. You could use it like so: $query_args = array( ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => array( ‘slug-of-category-a’ ), ), array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => array( ‘slug-of-category-b’ ), ), array( ‘taxonomy’ => … Read more

WordPress Query by Category using Post Slug

function namefunctions(){ $args = array( ‘post_type’ => ‘CPT’, ‘posts_per_page’ => -1, ); $recetax = new wp_query($args); while ( $recetax->have_posts()): $recetax->the_post(); ?> /* your content of ctp*/ <?php endwhile; wp_reset_query(); }

get_posts return only first result

// Get the category ID from url $catsearched = $_GET[‘product_cat’]; //printf($catsearched); $earth_radius = 6371; // Get products of category with in range distance $querystrShop = $wpdb->prepare(” SELECT productid AS post_id,(%d * ACOS(COS(RADIANS(%s)) * COS(RADIANS(phiz_geo_location.latitude)) * COS(RADIANS(phiz_geo_location.longitude) – RADIANS(%s)) + SIN(RADIANS(%s)) * SIN(RADIANS(phiz_geo_location.latitude)))) AS distance, phiz_postmeta.meta_value FROM phiz_geo_location JOIN phiz_term_relationships ON phiz_geo_location.productid = phiz_term_relationships.object_id LEFT JOIN … Read more