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

Questions tagged [get-terms]

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
1answer
10 views

get_terms only show term if there is a post using it

I have a custom post type called user_images. I would like to create some filters and populate the dropdowns dynamically. I am using the follow code: $post_type = 'user_images'; $taxonomies = ...
0
votes
1answer
8 views

$args for get_terms() to return ORDER BY FIELDS

I want to use get_terms() for a taxonomy in such as way as to emulate MySQL's ORDER BY FIELD e.g., ...FIELD ('aaa','ccc','bbb','eee','ddd') A var_dump snippet currently looks like: object(WP_Term)#...
0
votes
1answer
16 views

Is it possible to use array_walk() to append terms to an array of posts?

I'm creating a masonry post grid of animals. I plan to filter the the visible posts by toggling classes. The classes would in turn would be the post's. I'm using an MVC theme and would like to get ...
1
vote
0answers
23 views

How to order and count get_terms by specific post type?

I want to get a list of taxonomy "company" terms which have a particular meta value and which are associated with posts of custom type "viewpoint". Beginning with getting Viewpoint posts, as per ...
0
votes
1answer
50 views

Order get_terms() by hierarchy

I am trying to query a custom taxonomy terms in a way that keeps the hierarchical structure. Here is the code that I am using.. function ev_test_data() { $title = 'Mens Levi\'s Jeans'; $...
0
votes
0answers
13 views

how to display post of lowest terms - ancestors wise?

I want to achieve 3 post display from each taxonomy terms. But this terms will be passed from lowest of hierarchy in array that is ('munnar','cochin') etc. Europe Asia - India -- Kerala --- Munnar ---...
0
votes
0answers
24 views

Please: Display taxonomy child & parent

Newbie here! How would I modify this code to display the child (parent) ($show_count), like Station (Train Line)(#)? if( !empty( $train_station ) && ($hide_detail_prop_fields['train_stn']) != ...
0
votes
2answers
41 views

get_terms() but with additional dimensions?

How do I get all terms matching: custom taxonomy "company" only where term meta (ACF field) "tags" value matches a given string, "Publishing" only if the term has any posts of custom type "article" ...
0
votes
0answers
19 views

How to get_terms() only of terms matching an ACF meta value?

My custom taxonomy "company" has an Advanced Custom Fields field group with fields including a Checkbox, "tags". (This adds to each "company" term fields including "tags", which accepts multiple ...
1
vote
0answers
26 views

How to show all possible parents and children of a hierarchical taxonomy term?

I have a hierarchical custom taxonomy "company". Companies are hierarchical, they can have both owners and subsidiaries. So, some of my "company" terms have parents and children. Take this real ...
0
votes
2answers
42 views

Why is my custom taxonomy image not displaying?

I have created a custom image taxonomy field in WordPress using CMB2. I cannot get the images to display for website visitors even though my code uses get_term_meta. (The taxonomy images are amenity ...
0
votes
0answers
18 views

Get count of terms with a post and another taxonomy term?

How do I count the number of taxonomy terms which have both a) an associated post and b) where that post also has an associated term from another taxonomy? Specifically, I have... Custom post type "...
0
votes
0answers
14 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
23 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
28 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
42 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
53 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
26 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
31 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
46 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
29 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
39 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
79 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
138 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 ...
1
vote
1answer
177 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
18 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
201 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
648 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
128 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 ...
1
vote
1answer
46 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
45 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
33 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
33 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
233 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
2k 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
40 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
38 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
410 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
46 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
142 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
264 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
824 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
119 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
1answer
32 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
38 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
3answers
418 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
92 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
205 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 ...