Questions tagged [advanced-taxonomy-queries]
The advanced-taxonomy-queries tag has no usage guidance.
207
questions
19
votes
5
answers
15k
views
Modify Taxonomy pages to exclude items in child taxonomies
I found this question:
Theres a way to use $query->set('tax_query' in pre_get_posts filter?
which seems to indicate that yes, you can alter the taxonomy query on taxonomy archives via ...
12
votes
3
answers
23k
views
Taxonomy: Why 'with_front' => false DOES NOT WORK?
Seriously, why 'with_front' => false does not work as it should be? It is supposed to remove TAXONOMY BASE NAME and my question is why it does not work?
I just dont want the taxonamy base slug ...
10
votes
3
answers
50k
views
How to add images to taxonomies?
Q: Is it possible to add images to all of my taxonomies (default and custom ones)?
Note: I do not want to use any plugins (not my favourite solution for design related matters).
Usage: I want to ...
9
votes
3
answers
39k
views
Get url of product's images (woocommerce)
What happen when a post (product) didnt have a guid,because it has the same image with another product ?
For example:
Query1:
select guid from wp_posts where post_type='attachment' and ...
7
votes
1
answer
31k
views
Custom Taxonomy and Tax_Query
I've been having a lot of trouble getting a WP_Query running with a tax_query on my custom taxonomy.
I'm 99.9% sure that my register_taxonomy is correct, as I'm able to tag posts with the right term, ...
7
votes
1
answer
20k
views
How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
This answer provides the code for a query that returns an OR match on a taxonomy term:
global $query_string;
$args['tax_query'] = array(
array(
'taxonomy' => 'status'
,'terms' ...
6
votes
1
answer
19k
views
Is it possible to add custom fields to a WooCommerce attribute term? [closed]
On Wordpress / WooCommerce, is it possible to add custom fields to a WooCommerce attribute term?
With "attributes" I mean the general attributes and not the attributes under products.
Please, check ...
6
votes
1
answer
8k
views
How to modify the query in taxonomy-custom.php to sort term archives by a custom meta field?
I am trying to create theme pages for custom taxonomy terms in which the archives are ordered by a custom meta field.
I can do this with a new wp_query as follows:
<?php $...
6
votes
1
answer
874
views
Using multiple taxonomies to sort Custom Posts
I have a post type that includes a taxonomy for (1) location and (2) a day of the week.
I'm using the first taxonomy to sort the posts into groups. Here's the loop I'm using:
<?php
$terms = ...
6
votes
2
answers
469
views
Assign posts to taxonomy terms instead of the taxonomy terms to posts?
So I have a custom post type (people) with a related custom taxonomy (directory). Instead of editing a person and then choosing the related directory organizations I'd like to "edit" a directory org ...
5
votes
1
answer
3k
views
WP 5.8 "Query Loop" block: where to place custom query?
In the recent wordpress.org article outlining the new Query Loop block, it says the "Inherit query from template" option allows you to "customize the query that the loop relies upon ... ...
4
votes
2
answers
17k
views
wp_get_object_terms() to get a list of all the terms attached to all the posts in the current query
How can I use wp_get_object_terms() to get a list of all the terms attached to all posts in the current query?
For example, for the current query I want to get an array of the terms from the "Alfa" ...
3
votes
1
answer
13k
views
SQL QUERY needed to get POST category (taxonomy) ? - MUST be SQL statement
Working on a tool outside of Wordpress to query the wordpress database by POST_ID and return the Category Name associated. This is for a real estate website, and the Categories are called "...
3
votes
1
answer
2k
views
Exclude from search all custom posts which are NOT in a taxonomy term
I have a custom post with a taxonomy associated to it. That taxonomy only has one term, and posts either belong to it or not, in a boolean fashion.
On the search results, I wish to show the custom ...
3
votes
1
answer
7k
views
WP_query taxonomy + get all posts with two terms from same taxonomy
This is a follow up question to Add_query_arg + two times the same argument?
I want to get the post count from all posts tagged with 2 different tags from same taxonomy
$args2 = array(
'...
3
votes
2
answers
8k
views
Custom SQL Query on Custom Post Type. Order by Taxonomy?
I've created a custom post type called 'publications' and a custom taxonomy called 'topics'. I'm also using the standard taxonomy of 'category'.
My Custom Query makes sure that it fetches ALL '...
3
votes
1
answer
285
views
SQL Statement generated by WP_Query not producing expected results
I am trying to alter WP_Query on the pre_get_posts action hook, for filtering the posts returned, depending on the built-in category and post_tag taxonomies.
I would like that the only posts returned ...
2
votes
2
answers
16k
views
How to Get All Taxonomies AND All Terms For Each Taxonomy With Post Count Zero
Is there an easy way of obtaining every registered taxonomy and for each registered taxonomy, get all the terms for that taxonomy, and for each term, get the post count, without actually fetching all ...
2
votes
2
answers
3k
views
Advanced Tax Query
Below is my tax query, at the moment this returns all posts which have at least one of the specified terms.
Is there a way I can have it return only posts which have ALL of the specified terms?
[...
2
votes
3
answers
2k
views
Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
I need help with WP custom taxonomy and custom post types. I never find a working solution so far. Please accept my apologies if this has a simple solution. I tried my best to find solution everywhere ...
2
votes
1
answer
4k
views
Custom archive page based on array of categories and tags
I'm looking to create custom archive page based on passed arrays which contains categories and tags, for an example:
http://www.mydomain.com/archives-custom.php?c=cat1,cat2,cat3&t=tag1,tag2,...
2
votes
1
answer
4k
views
WP_Query use for a filter with multiple Taxonomies and Terms
So, what I'm trying to do, is to make an ajax filter, this is the portion of the filter code that builds the $args based on the data that came from the filter form, and afterwards (not in this code) ...
2
votes
1
answer
3k
views
tax_query shows no results if nothing is selected
I am creating a real estate website on WordPress, I am creating a custom search and am using tax_query to filter search results to display "States" & "Suburbs".
The search works fine, when ...
2
votes
1
answer
3k
views
WP_Query tax_query on ACF post_object
I have a custom post type Wine, which has an ACF Field that links to another custom post type Producer as a post_object relation. In my Producer, I have a custom taxonomy named Region.
Now, what I'm ...
2
votes
2
answers
4k
views
Improving WP_Query performance for multiple taxonomies
I have a site with several custom taxonomies, and have found that one of the slowest parts of the site is attempting to query with an OR across several of these at once. I'm using a WP_Query like so:
...
2
votes
1
answer
127
views
get complex results set according to category structure
I need to get a complex result set from a WordPress database according to the category structure.
First I will try to explain my category structure. I have three level structure as bellow.
flight [...
2
votes
1
answer
2k
views
Taxonomy , subtaxonomy,child taxonomy of a product woocommerce
Hi i need to get the main taxonomy and sub taxonomy of a product in woocommerce . i know how to get taxonomy details .123 is product id .
$terms = get_the_terms(123, 'product_cat');
I know how to ...
2
votes
2
answers
1k
views
Paginated Taxonomy Term Archive including one post per term
I have a custom query which gets all the custom taxonomies for the custom post type and displays the latest post in each. At the moment it pulls in all the taxonomies. Is there a way I can limit the ...
2
votes
1
answer
3k
views
How can I display all post IDs from the taxonomy?
I try echo on any page (I mean page on my site) all post IDs what I have in my taxonomy.
I found this:
get a list of posts from Custom Taxonomy
But I could not handle with it.
I want to echo all ...
2
votes
1
answer
1k
views
Get ID and slug from taxonomy object
I have a custom field to select a category (custom taxonomy) and then I will display a list of all of its child-categories. This works fine when I return the custom field as "term_id."
HOWEVER. I ...
2
votes
1
answer
337
views
Get image of latest post from taxonomies/categories
I have a custom post type "Artworks" with a custom taxonomy "Artists". I have a page where I list all the entries from the "Artists" taxonomy (Artist 1, Artist 2, Artist 3, etc.).
How can I get the ...
2
votes
0
answers
153
views
How to display custom taxonomy in multiple columns?
I have a custom taxonomy (with terms that include all 50 states) that I'm displaying, along with the title of the posts in that term directly below. Simple, and it's working as expected. However, ...
2
votes
1
answer
51
views
Related Tags Concept
On search results pages I would like to show a tag list collected from other posts that are listed for the seach result.
// same tag should not be listed twice
And for the taxonomy pages again; tags ...
2
votes
0
answers
799
views
Removing taxonomy query by pre_get_posts
I would like to remove taxonomy related SQL query part from the main query. I am trying to use pre_get_posts posts_where filter.
An example of original not modified query WHERE part:
WHERE 1=1 AND ( ...
2
votes
2
answers
2k
views
Custom taxonomies making WP very slow - Way to fix?
I've set up three custom taxonomies within my theme for attachment post types within Wordpress 3.5.1. One taxonomy is non-hierarchical (i.e. tags) and has about 800 terms in it. (I'm using WP to build ...
1
vote
2
answers
11k
views
How to count the number of terms in a taxonomy
I have a custom post type "Services". It has a hierarchal taxonomy of "service-category". Service-category has both parent and child terms.
I need to count the number of parent terms in the ...
1
vote
1
answer
5k
views
Exclude specific taxonomy term when using wp_get_post_terms
i have a single-post_type.php file where i constructud a breadcrumb (or similer to)
i am currently using this to get the terms of this taxonomy:
$terms = wp_get_post_terms( $post->ID, '...
1
vote
2
answers
13k
views
Get Taxonmy Term ID For Current Post
If I wanted to get the category ID for the current post, I would use something like this:
<?php foreach((get_the_category()) as $category) { echo $category->cat_ID . ' '; } ?>
How can I do ...
1
vote
2
answers
2k
views
wp_dropdown_categories and custom taxonomy + custom post type
I have created custom post type called "case study"(with slug case-study), with support of custom taxonomy which is called "theme".
What i am trying to achieve? Simple dropdown, ...
1
vote
1
answer
512
views
Query Custom Post Type Order By Taxonomy Field
This is driving me nuts. I know it's been asked a number of times but I can't figure it out. I'm trying to display a list of WooCommerce products--which are a custom post type of 'product'. I want to ...
1
vote
2
answers
2k
views
Sorting taxonomy columns by meta value numeric
Slowly going crazy over trying to make taxonomy admin columns sortable by a custom field number. I have a custom taxonomy called "typer" and these taxonomies have a custom field called "prioritet".
...
1
vote
1
answer
618
views
Multiple loops on page only show taxonomy name of first loop
I have a page with a custom post type called 'books', with taxonomy 'booktypes'. The books are ordered/divided in a loop per taxonomy-item, and added via shortcode to the page editor like this:
[...
1
vote
3
answers
13k
views
Display sub categories and their data of a taxonomy
I want to output the sub category details of a taxonomy
$getTerms = get_terms($taxonomy, $args);
print_r($getTerms);
When i print the above out it returns the object. But theres no value difference ...
1
vote
2
answers
5k
views
ACF: how do I get the fields and its values of a specific group? [closed]
<?php $fields = acf_get_fields('6066');
?>
<?php if( $fields )
{
foreach( $fields as $field)
{
$value = get_field( $field['name'] );
if ($value) {
echo '<...
1
vote
2
answers
59
views
How do I get a list of all categories that a given user has written blog posts for?
I need to retrieve the name of all the categories that a given user has published posts for. If I can also get a URL for the archive of that cat for that user only, this would make me very happy.
How ...
1
vote
2
answers
271
views
Shortcode to show thumbnail and link for 3 random posts
I want to have a small header at the top of a page showing the featured images with a link to the related custom post type.
This is my code:
// Creates random image header within tax called(defaults ...
1
vote
1
answer
861
views
Fetch all terms for an array of posts
I need to fetch all terms associated with an array of posts. I can loop over each post and do a seperate get_terms or wp_get_post_terms query for each post but that seems like a really slow way of ...
1
vote
1
answer
1k
views
Include posts from feature category in pre_get_posts
I have two custom taxonomy 'cities-taxonomy' and 'userfeed-taxonomy' and I am excluding all the post which has these taxonomies assigned in my blog page using pre_get_post();
Here is my query
...
1
vote
1
answer
7k
views
Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
I am trying to build an advanced search form that allows users to select from two taxonomy based drop down menus. Each taxonomy drop down has taxonomy terms from which the user can select multiple ...
1
vote
1
answer
760
views
Advanced Query Logic With Multiple Taxonomies
I have a page on my site that acts as a search tool/search results page for users to find rental spaces. On the left side is a column of checkboxes that let the user filter the results by three ...