Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Retrieve the terms in a taxonomy or list of taxonomies. Returns an array of term objects, or a WP_Error object if any of the taxonomies to get terms from does not exist.

0
votes
0answers
11 views

How do I show a list of terms' posts, grouped by a secondary taxonomy?

Let's say I have custom post type article. I have a custom taxonomy fruit, with terms like apples. And another custom taxonomy company, with terms like juicy-inc and crunchy-co. Both are associated ...
0
votes
1answer
22 views

custom hierarchical taxonomy and custom post type list contains surplus posts

I wish to list custom taxonomy terms as titles and custom posts as lists under titles: Basics List item1 List item2 Movies List item3 Images List item4 However, custom taxonomy is HIERARCHICAL ...
0
votes
0answers
26 views

Why is the term of my current page not returning a slug?

Why is the term of my current page (custom taxonomy) not returning a slug? I have managed to get the following returned in my URL: 0, Array, '/{empty space}/ I am trying to pass the custom taxonomy ...
0
votes
2answers
39 views

How can I change the output display of my pagination?

How can I change the output display of my pagination? I have been trying for the past few hours to format the output of my pagination links (1,2,3, etc.) to resemble the below: I have been unable to ...
2
votes
2answers
50 views

Problems with function on function.php

I've a problem with some functions on function.php. I want to use get_tems_by("slug", $slug, "category"); but it doesn't work inside a function on function.php. When i changed slug by ID and give a ...
0
votes
1answer
20 views

echo a tax term in loop

I need to echo a term of a CPT in this loop after the for each item in the list. Any direction or help is appreciated. Original code is from Stackoverflow.com because it worked. <?php $da_place =...
0
votes
0answers
20 views

Pagination for get_terms leading to 404

I have a very long list of categories in my Wordpress site (220 and counting). I want to set a custom page template where I can list all categories in alphabetical order, but being so many, I want to ...
1
vote
1answer
37 views

get_terms() order by term_meta

I'm doing a get_terms() query that I'm trying to order by a custom term meta. The custom term meta key is 'order' which as a numeric value (between 1 and 10). I have tried the following, but the order ...
0
votes
1answer
27 views

Count Number of Posts in Taxonomy Term in Last 24 Hours

if anyone could help it would be greatly appreciated, been trying to get this done on and off for a long time and just can't get there. I am using the function below in a loop to count posts within ...
1
vote
2answers
27 views

Term count by user

I am developing a section on the front of our website. Our users submit properties to our directory. we would like to show how many properties they have listed and what types. I have got this code but ...
0
votes
1answer
34 views

Matching slug terms from one array to those in array of WP_Term objects to output term names

I'm using WordPress's get_terms to return an array of WP_Term objects containing the term_id, name, slug, etc. for the child terms of a given taxonomy. I've saved this array to $tax_terms. I have a ...
0
votes
0answers
72 views

List all custom taxonomy terms related to another taxonomy

I want to list all custom taxonomy terms related to another taxonomy. For example the following case: Custom Post Type: Car Taxonomy 1: Brand ->Terms: Audi, Bentley, BMW, Bugatti, ... Taxonomy 2: ...
0
votes
1answer
20 views

Query for post term that matches user ID

I'm trying to set up something to decide wether the current post has a custom taxonomy term that matches the current users ID. So far I set up a variable that stores the taxonomy terms of the given ...
2
votes
2answers
107 views

How do I access a single term from a post?

I need help accessing a specific term from a custom taxonomy. I am getting the terms with $terms = wp_get_post_terms($post->ID, 'mytax', array("fields" => "all")); If I print_r($terms) this ...
0
votes
1answer
91 views

get_terms in a taxonomy template

I've two custom taxonomies, and two template archives: taxonomy-brand.php and taxonomy-producer.php If I insert $terms = get_terms('brand'); in the taxonomy-producer.php I can't get terms for the ...
0
votes
1answer
17 views

How do I get term data associated with the current post, where the result is not wrapped in HTML?

I'd like to get term data from a custom taxonomy associated with the current post. I can do this with get_the_term_list($id $custom_taxonomy). However, this returns the data I want wrapped in HTML. ...
0
votes
2answers
113 views

`get_terms()` with `child_of` and `childless` combined

I have a hierarchical taxonomy filter that contains locations and genres for posts with the custom type artist: - Genre -- Hip Hop -- Trap -- Rap - Location -- Europe --- Germany --- Sweden --- ...
3
votes
2answers
398 views

Exclude specific slug in 'get_terms'

I have a custom taxonomy "role" for my custom post type "People". When listing the roles, is there a way to exclude roles based on slug and not ID via get_terms function? I ask because I'm running ...
0
votes
1answer
78 views

Search Terms - Querying on either description__like OR name__like in the same Term Query?

In my theme's search.php I have a section set up to show terms that fit the search. I want the term to show up IF the $keyword appears in the term's title or its description. I have it set up to do ...
0
votes
1answer
30 views

Wordpress function to get term or post object by id

Currently to differentiate between post and term objects I use short piece of code: $object = get_post($id); if ( ! $object ) { $object = get_term($id); } print_r($object); Is there a function ...
0
votes
1answer
34 views

Using WP_Query for categories instead of get_terms

I have managed to get all parent categories from Woocommerce with this function $terms = get_terms( array( 'taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => 0 ) )...
0
votes
0answers
29 views

get_edit_term_link returning an empty string

Basically exactly what it says in the title. I have a custom admin page that is set up to deal with custom terms, except the vital part of get_edit_term_link is not working for me, and so therefore ...
0
votes
0answers
29 views

Immediate categorie children not grandchildren - get_term_children

I'm using a bought theme on Wordpress / Woocommerce. Actually in my categorie list, the theme display term children and grandchildren of a custom taxonomy This is my actual code : foreach ($...
0
votes
0answers
213 views

How to display all sub-categories of parent category even if inside sub-category

In Wordpress with WooCommerce I want to display all sub-categories of the parent category even if inside the sub-category. When I am in the parent category it works. I am missing something but can't ...
1
vote
2answers
1k views

Check if term object is in array

I want to check if a term object is in an get_terms array, but i really can't figure out how to do it. $subcat_terms = get_terms([ 'taxonomy' => 'product_cat' ]); $subcat_terms generates an ...
3
votes
0answers
39 views

Count argument in get_terms has no effect on ouput/doesn't work

I'm trying to get a count of the categories that are subcategories of a category with the id $categoryId. In the documentation for the term query object, which is the primary argument to get_terms, ...
0
votes
0answers
35 views

Exclude Woocommerce category with specific field value

I need to exclude certain categories ONLY from the Woocommerce shop page loop. Not the products, but only the categories. While I can still display these categories on the frontpage and such. With ...
0
votes
1answer
346 views

get_terms() returns Trying to get property of non-object error for custom taxonomy

Created custom post type and now I'm trying to create a custom taxonomy. Once I create it and try to access it with get_terms() I get an error of non-object. Var_dump is giving me an empty array ...
0
votes
0answers
45 views

wordpress does not see the correct custom taxonomy hierarchy

I have created custom post type - 'portfolio' with custom taxonomy designating the category and subcategory. I have an example structure: - main_category: -- subcategory_1 -- subcategory_2 The ...
0
votes
1answer
132 views

SOLVED Custom Add rewrite rule and Get string

I have a problem, I try to create clean urls for seo. but I do not get any parameters using GET, which is wrong in my code add_action( 'init', 'listing_search_url' ); function listing_search_url() ...
0
votes
1answer
230 views

wp_dropdown_categories - how to save in widget?

I'm trying to use wp_dropdown_categories in a custom widget. Everything is displaying nicely but for some reason it's not saving properly. Here are the form() and update() functions from my widget - ...
0
votes
2answers
639 views

Get Term names from WP Term Object

I created an array with this expressions: $taxonomies = get_terms(array( 'taxonomy' => 'product_cat', 'hide_empty' => false, )); And I got this as return: Array ( [...
0
votes
1answer
101 views

Ive got a term (get_term_by) but now I want to filter it by a category it is in?

So I have my term, here is an example: $term = get_term_by('slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); This, for example, will return all 'Females' which is OK but now I only ...
0
votes
0answers
16 views

Get WooCommerce Terms Help

I have an app I built a while ago and has been working great. I updated woocom and extensions, memberships/subscriptions yesterday and now it is not working. I have an API call that hits a function ...
0
votes
0answers
262 views

Display custom taxonomy child terms with category image on parent term archive

I have a CPT with a custom taxonomy called 'equipment_cat'. I'm currently displaying the subcategories of a category on the category archive using the following code: <?php $term = get_term_by( '...
0
votes
1answer
30 views

echo a specific custom taxonomy term on a different custom taxonomy archive

I'm not having much luck trying to find anything to help with this... I have a custom taxonomy('XYZ') archive all the posts in this archive also have an other common custom taxonomy('ABC'). I'm ...
0
votes
1answer
36 views

Get only selected custom taxonomy

I have this code: $post_types = get_post_types(); if($post_types) { foreach($post_types as $post_type) { $post_type_object = get_post_type_object($...
0
votes
0answers
13 views

Getting specific taxonomies from post type in an array

I have this code: $choices = array( 'all' => __("Filter by Post Type",'acf') ); if( in_array('all', $field['post_type']) ) { $post_types = apply_filters( 'acf/get_post_types', array() ...
0
votes
3answers
343 views

Query to get term id using post id?

I know there is connection between post table with term table but I am unable to figure it out. wp_terms, wp_termmeta, wp_term_relationships & wp_term_taxonomy relation is a little confusing. So,...
0
votes
1answer
62 views

Display custom taxonomy on single post

I have 4 different custom entries from my custom category. Categories are: john-doe, jane-doe, john-does, jane-does Each of the user have different posts. Let's say John Doe have a post, but on that ...
0
votes
0answers
179 views

Get Highest and Lowest get_term_meta() value from Taxonomy Term

I have a Taxonomy and it named "synagogue". I made this query: $synagogue_terms = get_terms( 'synagogue', array('hide_empty' => false)); Here two Term fields lat and lang, which is Lattitude and ...
0
votes
4answers
72 views

Display children category images

I have worked four hours on this but with no result. There is a custom taxonomy and I need to display the image of the child category but displays the image of parent category. My code is: <?php ...
0
votes
2answers
153 views

How do I display the taxonomy for a custom post type in an array

I am trying to display the terms from a taxonomy on my archive page but I am struggling to display the terms name, here is what I have so far: if ($post->post_type == 'cpt_saving') { $...
1
vote
1answer
67 views

Avoid duplicate post from same Taxonomy

I have this to retrieve a list of post typed named "works" based on a taxonomy called "works_year". If I select more than 1 value of that taxonomy (works_year), that post are being duplicated on my ...
1
vote
2answers
339 views

get_terms 'number' parameter does not appear to work

Why doesn't the get_terms() call return 10 max results as requested? I'm baffled. $args = array( 'taxonomy' => 'video_tag', 'parent' => 0, '...
4
votes
2answers
263 views

Front End Post Save Child terms

Im trying to update my front end post form which allows me to save my custom taxonomy parent term, but now I need to save the child term that's selected. NHB is for Neighborhood which are child terms ...
0
votes
2answers
47 views

return only the first two terms of custom post

hey im trying to figure out how i can display only two terms that are associated with a custom post type. I tried using $wpdb but that doesn't work for me since i need the term links as well. any ...
0
votes
1answer
108 views

How to show terms used only for particular custom post type. Filter creation perpose

everyone. I have 10 custom post types and they are sharing 5 taxonomies. Right now I am working on the archive page template where I want to create ajax filters based on taxonomies for each of the ...
0
votes
2answers
114 views

How to get terms from a custom taxonomies after WordPress 4.5.0

I have been developing the shortcodes for which am pulling the terms of custom taxonomies from a plugin. It was working fine prior to WordPress 4.5.0 and now realized it is not working after 4.5.0. I ...
1
vote
2answers
1k views

get_terms parent for current product only

I wish someone can give me a clue. I am actually displaying all product category (product_cat taxonomy) on single page products, displaying also childs regarding the product itself. For instance: ...