in tax_query this Is the code correct? I need to access beginner video posts for different subject

try this.. $args = array( ‘post_type’ => ‘videolesson’, ‘ordeby’ => ‘rand’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 8, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘level’, ‘field’ => ‘slug’, ‘terms’ => ‘beginner’, ‘compare’ => ‘IN’, ), array( ‘taxonomy’ => ‘subjects’, ‘operator’ => ‘EXISTS’ ) ), ); $getting = new WP_Query( $args );

WordPress tax_query ignoring relation OR

I’ve came up with the not perfect solution to this: Because I am using term_taxonomy_id I can just add all the IDS and remove the taxonomy specification like this: ‘tax_query’ => array( array( ‘field’ => ‘term_taxonomy_id’, ‘terms’ => array(…all ids…) ) ) And it works! This is a quick solution, although it will work in … Read more

Order WordPress Query by Custom Field While Still Using Tax_query Argument

You can use a meta_query in addition to your tax_query : https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters I have in which if statement you want to use it so I put it in the of the code. $names = array( ‘fields’ => ‘names’ ); $prac_names = get_terms(‘attorney-practice’, $names); $prac_matches = array_shift(preg_grep (‘(‘. $search .’)’, $prac_names)); $off_names = get_terms(‘office-location’, $names); $off_matches … Read more