How to get related taxonomies based on a category with mysql query?

I have a lot of custom taxonomies for my WordPress site. What I want to do is to Get Related Custom Taxonomies based on a Category. Sample Structure: (Material, OS and Features are Custom Taxonomies.) Post Category (CT)Material (CT)OS (CT)Features P1 A iOS OLED P2 B Metal GPS P3 C Glass Anroid GPS So what I want: For Category A: its related taxonomies is OS and Features. For Category B: its related taxonomies is Material and Features. For Category C: …
Category: Web

Filter custom posts by multiple taxonomies

Im working with custom post types - named 'Products' I have multiple taxonomies registered - 'Category' and 'Dosage' And I'm trying to setup pages that only display custom post types 'products' IF taxonomy Category='injectors' AND Dosage='1ml, 2ml, 5ml' I hope that makes sense - manage to get custom post archives working fine for a single taxonomy, but not sure about filtering by multiple. Cheers, This is the code i'm trying to get work but it doesn't <?php $myquery['tax_query'] = array( …
Category: Web

Custom taxonomy and query multi conditions

I have this query $query->set( 'tax_query', array( 'relation' => 'OR', array( 'taxonomy' => 'location', 'operator' => 'IN', 'field' => 'slug', 'terms' => $availableRegions, ), array( 'taxonomy' => 'location', 'operator' => 'NOT IN', 'field' => 'slug', 'terms' => $notavailableRegions, ) )); and it's return this sql query SELECT wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) JOIN wp_icl_translations t ON wp_posts.ID = t.element_id AND t.element_type IN ('bla') JOIN wp_icl_languages l ON t.language_code=l.code AND l.active=1 WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id …
Category: Web

Combining categories (Query posts with multiple taxonomy terms)

I'm attempting to display a list of all posts from multiple categories (if anyone answers this, you might want to include combining tags as well, as probably that will make this answer comprehensive for future seekers). Here's what I'm working with: This function works to show a list: function my_custom_loop_three_posts($category, $tag, $offset) { $args=array( // showposts has been replaced, use 'posts_per_page' instead // 'showposts' => 1, 'posts_per_page' => 3, // this has been replaced, use 'ignore_sticky_posts' // 'caller_get_posts' => 1, …
Category: Web

WP Tax query & order by tax query not working

I have subcategories(custom taxonomy).I want to fetch all products of that category in one table & then other category name & it's table. To achieve this,I grouped by & ordered by custom taxonomy.Also, I want to pass parent category (custom taxonomy) id to the query. But when I pass these 2 conditions at a time , no data is returned. /* to order by taxonomy*/ function orderby_tax_clauses( $clauses, $wp_query ) { global $wpdb; if ( isset( $wp_query->query['orderby'] ) && 'product_category' …
Category: Web

Custom taxonomy: on the taxonomy term page show other taxonomy terms

ok, i have a custom post type LAW and two taxonomy LAW TYPE and EDITION I create a page taxonomy-law_type.php for display child terms LAW TYPE <ul class="wpb_page_list"> <?php $term = get_queried_object(); $children = get_terms( $term->taxonomy, array( 'parent' => $term->term_id, 'hide_empty' => false ) ); if ( $children ) { foreach( $children as $subcat ) { echo '<li style="display:flex"><a href="' . esc_url(get_term_link($subcat, $subcat->taxonomy)) . '">' . // wrapped $subcat->name . ' (' . $subcat->count . ')' . '</a></li>'; } } …
Category: Web

How to filter custom post type by multiple Taxonomies

On the project there is a filter: It should filter the custom post ty recipes. Selected items are checkboxes. So, several values for filtering can be selected at any time. But in my case, filtering works only on one selected element. For example, I chose 'Lorem inpus1' the recipes were filtered by it. Now I choose any other element 'Lorem inpus3' for example and previous results removed. Here is my code. I think the reason is in it, but I …
Category: Web

Show posts from two specific category in WP_Query

I've two category employee and full-time. If a post publish in both (employee and full-time) category then the post will show in his specific section. If post has only employee category, not full-time or has only full-time, not employee, then this post will not show in the post block. How can I do this? What will be the query of this relationship between two category?? Here is my code - 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'category', …
Category: Web

Query all post and CPT from 2 specific taxonomies AND by ACF custom field

I need to build a complex query. I want to display all posts, and 2 different CPT posts in specific taxonomies. All of these posts need to have been checked to be displayed. The checkbox is added with ACF. My ACF checkbox is named highlight and the value needs to be yes. So my query should display: all posts of all categories but with the ACF checkbox checked all post of the CPT1 with the taxonomy TAX1 and ACF checkbox …
Category: Web

How to get custom taxonomy terms based on another taxonomy?

How to list out all the terms of a custom taxonomy that are relative in another custom taxonomy? I am creating a filter page for a CPT with multiple custom taxonomies. Please see the screenshot below: Custom Post Type: English "cpt_english" Custom Taxonomy: Courses Terms: course-a, course-b, course-c Custom Taxonomy: Difficulties Terms: easy, advanced , pro Custom Taxonomy: Tasks "tasks" Terms: task1, task2, task3, task4 The screen is html markup, not php generated code. Question: How can I list out …
Category: Web

Query 1 taxonomy term, exclude another

Here's the code I'm using to try and query a single taxonomy for one term, but exclude returned posts for that term that also belong to another. In English, this is what I want: query 'resource-type' for 'testimonies', but not 'testimonies' that are also 'audio'. Tips to tweak this code to get it to work? <?php $testimonials_args = array( 'post_type' => 'resource', 'posts_per_page' => 1, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'resource-type', 'field' => 'slug', 'terms' => …
Category: Web

How to build a achieve page for a custom CPT with multiple taxonomy button filter

This is an extended question from Permalink for CPT with taxonomy I am building a website that has a CPT and a few custom taxonomies. Each single CPT post is basically "a question" for student to practice with. I would like to setup a "taxonomy filter page", so user can quickly find the one they are looking for in the right categories. I am creating a "CPT & Taxonomy filter" page to serve this purpose. Note that the CPT archive …
Category: Web

Formulate a url to show posts with both taxonomy terms

I would like to show an archive of posts that have two taxonomy terms in common. So for example, I'd like to show all posts that have both the terms "sauce" and "cheese" in the custom food taxonomy. The trick is that I'd like to do this using the url. The closest I've come is with: example.com?food[]=sauce&food[]=cheese Upon inspecting the $query from the pre_get_posts filter, I can see that: WP_Tax_Query::__set_state(array( 'queries' => array ( 0 => array ( 'taxonomy' => …
Category: Web

ACF multi taxonomy on filterable gallery

I created a filterable gallery with ACF. My problem is that when I add a project to which I add several taxonomies, in my gallery I have the project as many times as I have added taxonomies. Apart from that, I would like the project to appear only once in the gallery but to appear in all the filters where the taxonomy is selected. <div id="filters" class="col-3"> <ul class="nav"> <li data-filter="all" class="filter active">Tous les projets</li> <?php // 1. On définit …
Category: Web

WP Query by 4 different taxonomies

I need to make a shortcode that uses the values of four different taxonomies. I am trying to modify code that I have used to query attachments (in media) based off of multiple taxonomy terms, but what I need is to wp_query based off of 4 (four) taxonomies values. I realize that I am way off, but perhaps somebody can help put me on the right track. The Four taxonomies are: media_language media_document_category mp_industry mp_product_lines I want to use a …
Category: Web

Get custom taxonomy terms that contain posts that have another taxonomy term

I have two taxonomies for my property post type: property-style which has terms for different home styles like "Country" and "Modern", and property-tag which has terms for amenities such as "Swimming Pool" and "Garage". On the main page I list all of the property-style terms with the post count: Classic [1 Post] Country [0 Posts] Modern [4 Posts] Rustic [3 Posts] I get these terms by using: $terms = get_terms( array( 'taxonomy' => 'property-style', 'hide_empty' => false, 'orderby' => 'name', …
Category: Web

Custom Taxonomies Archive Page 404

I used the "Custom Post Types UI" and "Custom Fields" plug-ins to set up my structure. I have a custom post type called "artwork". This works fine. Posts have URLs like domain.cc/artwork/title-of-some-random-artwork. When I enter domain.cc/artwork, I get an archive page with all posts of the post type "artwork". That's how it should be. Within the "Artwork" post type, I have taxonomies for "Artist", "Movie" and "Company" (connected to custom fields which can be filled in when I entered a …
Category: Web

simple tax_query intersection

I'm trying to do tax_query for posts that have a term1 in taxonomy1 AND a term2 in taxonomy2 if I do: 'tax_query' => [ 'relation' => 'AND', [ 'taxonomy' => 'taxonomy1', 'terms' => 'term1', ], [ 'taxonomy' => 'taxonomy2', 'terms' => 'term2', ], ], I get all post with term1 in taxonomy1 AND all post with term2 in taxonomy2. I want the posts containing both terms: term1 and term2. Thank you. [EDIT. ACTUAL CODE] First, I recover al terms of …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.