Taxonomy Query Relation field not behaving correctly?
Taxonomy Query Relation field not behaving correctly?
Taxonomy Query Relation field not behaving correctly?
Searching in title or meta, with a tax query too!
You can use below code to search in taxonomy. First using name__like in get_terms it will return all terms ids which have $keyword then that ids use in wp_query. $termIds = get_terms([ ‘name__like’ => $keyword, ‘fields’ => ‘ids’ ]); $args = [ ‘post_type’ => ‘movies’, ‘tax_query’ => [ [ ‘taxonomy’ => ‘actors’, ‘field’ => ‘id’, … Read more
WP_Query | Tax_Query Relation | Unable to use ‘OR’ as it then allows all products, help me finish my query?
There is an example of how to do this on the official doc for WP_Query: https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters Specifically, by declaring multiple items in the tax_query and setting their relation: Display posts that are in the quotes category OR have the quote post format: $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘OR’, array( … Read more
Is it a good idea to improve meta query performance by adding tax query?
I believe you can add the following to the theme’s functions.php & visit /courses/?topics=foo,bar to get the results you’re looking for: <?php /** * Custom search-query with taxonomy filter */ function wpse373353_search_query( $wp_query ) { // exit early if this isn’t that main loop on the front-end of the site if ( ! $wp_query->is_main_query() || … Read more
Manipulate WP Query using a custom post type and multiple tax_query taxonomies
Unfortunately, there doesn’t appear to be a way grab terms “LIKE” a name or slug. See the Taxonomy Parameters in WP_Query. What we can do is break this up into two queries though. Get the term IDs by a partial slug match. Query posts assigned to those term IDs. We can either do this with … Read more
Terms generally should have a count parameter that you can use. I’m not sure if this is accurate across multiple post types though. This may not be the fastest solution but one option could be the additional parameters for WP_Query to both reduce the number of queries and the returned values. 10up has a good … Read more