Articles of advanced taxonomy queries

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 the same for a a term ID from a specific Taxonomy?

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 “mi_neighborhoods” and are referred to by wp_term_taxonomy.taxonomy. In one of my other queries to get all the Category names I use: SELECT * […]

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, ‘wedding_cat’); . Later on i am showing that term like this: <div class=”breadcrumbs”><?php $term = array_pop($terms); echo ‘<a href=”‘. get_bloginfo(‘url’) .'”>’. __(‘Home’, ‘sagive’) . ‘</a> &raquo; […]

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: [books booktypes=”cityguides”] [books booktypes=”travelguides”] [books booktypes=”languageguides”] So I have for example: (loop 1) CITYGUIDES Cityguide 1 Cityguide 2 Cityguide 3 etc. (loop […]

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 taxonomy. NOT posts. The # of terms in the taxonomy is being used in my code to layout the page in a recursive […]

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 first. Explanation of issue – I have one taxonomy called “department”. I have 3 CPT called “course”, “faculty”, […]

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 get taxonomy name also echo $terms[0]->name But my need is: Nokia 3110 is my mobile . So it […]

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 options are selected. However if nothing is selected, no search results will display at all. This is a problem with a real […]

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 number of taxonomies displayed to a set number per page and paginate them? // Set […]

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: array( ‘tax_query’ => array( ‘relation’ => ‘OR’, array(‘taxonomy’ => ‘tax1’, ‘field’ => ‘slug’, ‘terms’ => ‘term1’), […]