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

How can I get the last 5 element of this tax query?

add the ‘date_query’ parameter to your query and include the current year. $args = array( ‘post_type’ => ‘news’, ‘posts_per_page’ => 5, ‘post_status’ => ‘publish’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘week’, ‘field’ => ‘slug’, ‘terms’ => date(“W”, strtotime(“this week”)), ) ), ‘date_query’ => array( array( ‘year’ => date(“Y”) ) ) );

Custom search for a custom post type in WordPress

Change operator to IN: array( ‘taxonomy’ => ‘features’, ‘terms’ => $feature_slugs, ‘field’ => ‘slug’, ‘operator’ => ‘IN’, ), That will query posts that have any of the terms in $feature_slugs, rather than all of the terms, which is what AND does. Also, I can see you’re using the POST method for this search. That type … Read more

Query child posts with tax query on parents

My solution to this ended up splitting this into 2 queries: Get the IDs of all the parent products I want to ignore Get all the variations that don’t a post_parent from that list of IDs $archived_products = wc_get_products( array( ‘type’ => array( ‘variable’, ‘variable-subscription’ ), ‘paginate’ => false, ‘limit’ => -1, ‘category’ => array( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)