Stack Exchange Network

Stack Exchange network consists of 175 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
0answers
19 views

Add list with categories to choose from and save it as the category for the post

I have a solution for the fact that users can now add categories to their posts. Problem: they don't know which already exist and which do. Therefore, I'd like to go to a route where users can choose (...
-1
votes
2answers
27 views

get_terms() - unexpected '=>' (T_DOUBLE_ARROW) error

I am trying to get the terms from all the taxonomies in an array. but this throws an error like this ..not sure why. Is it the wrong method?: Fatal error: syntax error, unexpected '=>' (...
0
votes
0answers
34 views

Restrict retrieved terms by category?

Is there a way to add a layer to the terms to be able to only retrieve the terms based on a category? I have terms attached to multiple different categories, but a lot less in individual categories. ...
0
votes
2answers
19 views

Filter “get_terms” query

I'm currently getting the data from a custom taxonomy using this: $terms = get_terms(array( 'taxonomy' => 'my_custom_taxonomy_name', 'hide_empty' => true )); Now, this returns a lot of ...
2
votes
1answer
92 views

Output the slug and name of a CPT single post taxonomy term

When I'm on a single post for a custom post type, I want to be able to grab the slug and name of the taxonomy term so I can insert them into a link. Below is what I've tried but it doesn't seem to ...
0
votes
1answer
30 views

Only return taxonomies that are linked to a category & product

What's the best way, to return taxonomies, but only taxonomies that are linked to a product, within the category, I have a heirachial taxonomy, I want to get all the top level options, once an option ...
0
votes
1answer
19 views

How to solve/debug get_terms suddenly showing no results?

Up until I just discovered, my taxonomy-company.php theme file was successfully generating an indented list of each "company" taxonomy term's corporate family tree. That is, company is a hierarchical ...
1
vote
1answer
47 views

Get terms ordered by post date

What I'm trying to achieve: get n terms from a custom taxonomy ordered by the newest post in each term. This will be used to display the newest m posts under each term. Is there a better way of doing ...
0
votes
2answers
23 views

Filter Custom Taxonomy Posts

I have a custom taxonomy page, it also has a slider up top. The problem is the slider displays random posts from all taxonomies rather than the current taxonomy. Is there a way to filter the images in ...
0
votes
1answer
25 views

Advice on creating a WP Archive Template with Custom Taxonomy (get_term_meta)

I have created some custom taxonomies (using WordPress Pods) and they work great - but there's just one thing that I need them to do, and here's my question: How do I go about creating an archive ...
0
votes
1answer
30 views

Getting the post terms 'wp_get_post_terms' per post when within the functions.php file

I have used a form with an Ajax action to pull post information through on submit. It works a charm. However, I have used categories to separate the work into categories. One of which is the brand. ...
0
votes
2answers
36 views

Order get_terms by multiple values

Orderby of get_terms() does not accept array type. How do I make this code works? $allcities = get_terms( array( 'taxonomy' => 'city', 'hide_empty' => false, 'orderby' => array( '...
0
votes
1answer
10 views

Get All Taxonomy Terms From Get_terms Array With Specific Array Key

I have below code to extract all terms from multiple taxonomies, $taxonomies = array('ingredients','category','course'); $args = array( 'hide_empty' => 0 ...
0
votes
1answer
20 views

get parent and childs from hierarchcial taxonomy

I have a hierarchical taxonomy and I want to show only children from 1 parent. For example, the taxonomy looks like this: - Events -- Location -- Date - Region -- State -- StateCode When I use my ...
0
votes
1answer
95 views

I want to customize the_posts_navigation function by replacing prev and next with images

Hie, I am currently trying to customize the function 'the_posts_navigation' of Wordpress because I would like to let appear only "previous" and "next" (which I want to replace by icons of arrow in ...
0
votes
0answers
36 views

How to show hierarchical term tree from current term down?f

I have a taxonomy, company, wherein companies exist hierarchically. When I'm on the term page for a company, I want to show a list of all companies within its corporate tree, up and down... That is, ...
0
votes
1answer
32 views

Get all posts for custom taxonomy term

I have a custom taxonomy how-to-guide-type and I have some terms setup in this taxonomy. I want to display ONLY the posts assigned to each taxonomy term. I have the following but I can only seem to ...
0
votes
2answers
26 views

get_terms with posts that have a different taxonomy with term x

Here's the situation; I am using get_terms to retrieve all terms from Tax 1 with posts associated with it. Using the following $args = array( 'hide_empty' => 0, '...
0
votes
1answer
23 views

Display post after choice two taxonomy terms

I display post by a term filter (first taxonomy) and it works very well. I add an other list of terms filter (second taxonomy). I would like to display posts after choice a term in each taxonomy. ...
0
votes
1answer
24 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
104 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
33 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
63 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
2answers
180 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
18 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
27 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
45 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
134 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
33 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
106 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 ...
1
vote
0answers
33 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
17 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
45 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
30 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
54 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
57 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
46 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 =...
1
vote
1answer
125 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
35 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
36 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
51 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
117 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
22 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
236 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
400 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
30 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
500 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
1k 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
336 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
83 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 ...