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.

learn more… | top users | synonyms

8
votes
2answers
4k views

get_terms by custom post type

I have two custom post types 'country' and 'city' and a shared taxonomy 'flag'. If I use: <?php $flags = get_terms('flag', 'orderby=name&hide_empty=0'); I get a list of all terms in the ...
6
votes
1answer
3k views

What is 'term_group' for 'order_by' in get_terms()?

I was just reading the Codex regarding get_terms();. What exactly is the parameter 'term_group'? You can use it in (example): 'order_by' for get_terms();. Hint: I could be all terms that share the ...
5
votes
2answers
949 views

get_terms vs. get_categories: does it matter?

I'm fairly new to wordpress and am coming across new things each day - one was today when I happened across get_terms and noticed that it was basically the same as get_category. Any particular ...
4
votes
1answer
232 views

Return only the custom sub-term for custom post type, do not echo term-parent

I've made a custom function that retrieves the custom taxonomy term for a list of posts in a query, and echos both the name and the link. Additionally, it also excludes listing a term if I specify the ...
4
votes
1answer
602 views

get_terms() How many is TOO many?

Working on revamping a plugin of mine when I noticed that wp_count_terms() is not reflecting the same number as a call to count( get_terms() ) with the same $args passed. I'm pretty sure this is a bug ...
3
votes
5answers
12k views

Get the the top-level parent of a custom taxonomy term

How would I get the top-level parent of a given term? I am using wp_get_object_terms to get taxonomy terms on posts, but instead of showing all tagged terms, I only want to show tagged terms' ...
3
votes
2answers
1k views

get term by id without taxonomy

Can I get the term by it's id without knowing to whish taxonomy it belongs? I have a meta field that stores term ids, but doesn't store the taxonomy. However, all the get_term function have taxonomy ...
3
votes
1answer
630 views

Control term order on a per-post basis

I have a taxonomy in which term order matters, but varies from post to post. So I want to be able to set the order that terms are displayed in on a per-post basis: My first post | Tagged: Apples, ...
3
votes
1answer
102 views

Is there any difference between post in child term and child & parent terms?

This may be really obvious, but I can't find other documentation or questions about it. Scenario I have a directory of Businesses (custom post types). Each Business has a "Type" (custom taxonomy). ...
2
votes
1answer
6k views

How to only list the child terms of a taxonomy and not their parents?

I'm creating an age select menu in the admin, populated from a taxonomy of age. The taxonomy is hierarchical as follows: 18-25 (parent, ID 183) 18 (child) 19 20 21 22 23 24 25 26-30 (parent, ID ...
2
votes
1answer
1k views

Custom taxonomy term as class?

I'm trying to add a class to a container within a query, ideally I'd like to use the terms from a custom taxonomy I have setup (guide-categories). As an example: <div class="myclass *taxonomy ...
2
votes
1answer
101 views

Restrict filter to run only inside specific function

I would like to filter get_terms(), but I only want to filter get_terms() when it is called from the wp_terms_checklist() function. I am looking to add a "No term" option to the end of my checklist ...
2
votes
1answer
51 views

Does WordPress Offer a Way to Find All of the Categories that Don't Have Children?

Background As discussed in Is There a Difference Between Taxonomies and Categories, taxonomies refer to a generalized system of classification and organization of objects or data. In the case of ...
2
votes
2answers
10k views

Display current taxonomy term when inside custom post type

Well, this should be pretty simple, however I couldn't find answer anywhere on the web. all answers I found were close but no exactly what I needed. what I need is to display just the current term of ...
2
votes
1answer
182 views

Sort a custom post type array numerically

We've set up drop down lists to allow people to filter posts based on custom post types. In order to populate the drop down list I am using: <?php $terms = get_terms("ratios"); $count = ...
2
votes
1answer
416 views

Display custom list of tags in post/page editor with hooks

I used the information posted on this blog post to display specific tags when editing a post. The editors on my site wanted the ability to display pre-specified tags instead of the most popular ones. ...
2
votes
3answers
540 views

get_terms orderby name as numbers

I have a custom taxonomy filled with terms such as 'volume 1', 'volume 2', 'issue 1', 'issue 2', 'issue 10' and get_terms orderby name returns list as: issue 1, issue 10, issue 2 though I need it to ...
2
votes
4answers
3k views

show tags of custom post type ONLY

I have a custom post type with tags included as a taxonomy, I am trying to display a list of all the tags that are in the custom post type only. I initially used: wp_tag_cloud(); which generates ...
2
votes
0answers
208 views

Display Terms for all posts in Current Archive or Query

I am using the following code to create a list of linked terms belonging to a taxonomy. <?php $taxonomy = 'taxonomy_name'; $queried_term = get_query_var($taxonomy); $terms = get_terms($taxonomy, ...
1
vote
4answers
1k views

Count posts that have specific taxonomy term attached

When upgrading our portfolio I'm looking for something that shows the number of posts in a (current) category of a post type. Example: I have a category with 'features'. Each feature has it's own ...
1
vote
2answers
5k views

Advanced custom fields - taxonomy terms images [closed]

I used the Advanced Custom Fields plugin to add a custom field to my taxonomy. That custom field is an image which is associated with the term. Now I have a page where I display a list of all terms ...
1
vote
2answers
509 views

get_terms with more than x post count

Is there an argument for get_terms which I can fetch terms that only have say over 2 posts associated with it? I have a terms page which lists all my terms for 'artists', the page is huge but a lot of ...
1
vote
1answer
53 views

Get parent id by term id

I have the id of a term. Which is the function to call to get the parent id of the term?
1
vote
2answers
6k views

Woocommerce get cart total price in a number format [closed]

Is it possible to get the cart total price without any markup. So without the € symbol? Right now I'm getting the amount with: $totalamount = $woocommerce->cart->get_cart_total(); this ...
1
vote
2answers
236 views

Have a Custom Post Type index page display taxonomy items instead of posts

I have a CPT registered that is called lessons with a custom taxonomy (category) that is called courses. I want the /courses page (archive-courses.php?) to display the individual courses (i.e. "online ...
1
vote
2answers
232 views

get_term_children returns WP_Error for custom taxonomy

What I'm working on is a ajax based dropdown option form which returns child terms based on the option selected. When the option is selected, a function is fired using onchange, where the script ...
1
vote
1answer
423 views

get_post_terms not working as expected

I have a custom post type called "Fruit" and under this I have a hierarchical taxonomy called, "Fruit Categories" When I create a new post under Fruit, I am able to assign it to a "term" - like you ...
1
vote
3answers
1k views

Using get_terms for custom taxonomy in functions.php

I`m trying to retrieve the names of taxonomy items and include them into a theme admin panel. function retrieve_my_terms() { global $terms; $terms = get_terms('taxonomy'); foreach ...
1
vote
2answers
285 views

How to add terms to my tax_query based off of the current post

I need the terms in my tax_query to be the ones from the current post. I am trying to this by using a variable. The value of the variable is given by using the get_terms() function. The problem is ...
1
vote
1answer
282 views

Exclude main blog from get_blogs_of_user

I use WordPress Multisite and in the sidebar i have a box that shows a list of blogs the logged in user is a member of. I'm looking for a way to exclude the mainblog from this list. The main blog ID ...
1
vote
1answer
420 views

how does get_term_by know which term to return when the same term appears twice in a hierarchical taxonomy?

This is from the codex. <?php get_term_by( $field, $value, $taxonomy, $output, $filter ) ?> Suppose I have a taxonomy system as follows; taxonomy: "healthy foods" and it's a hierarchical ...
1
vote
1answer
26 views

Display a list of certain categories by ID

I have a list of custom taxonomy IDs like (1, 2, 3, 10). I want to display a list of these specified categories by names and each should have its childs like: Europe France Germany Africa ...
1
vote
2answers
97 views

Custom Post Type archive loop separated by term, in specific term order

I have a custom post type registered (our-team) and I have a taxonomy (team-categories) with multiple terms. Each term has multiple posts assigned to it. On my custom post type archive ...
1
vote
1answer
169 views

Output terms to post_class()

I am trying to output all terms attached to a specific post (including custom taxonomy terms) as CSS classes applied to a DIV Something like that : <div <?php post_class('class-name'); ...
1
vote
1answer
1k views

Use get_terms to get post_tags but limit to a taxonomy

So I'd like to get the top 5 post_tags by count. But I have an additional taxonomy that I use to further organize posts called Issue. So I want to be able to get the top 5 post tags used by posts in a ...
1
vote
1answer
233 views

Echo custom taxonomy term name

I would like to echo out the term name from a custom taxonomy 'recipes' but all I get is the word "recipe" when it should say eg "pizza recipe". Is name the right argument here or I am mistaking it ...
1
vote
1answer
434 views

How to determine the depth of a term in a custom taxonomy?

I'm building a <select> dropdown to display a list of terms for a custom hierarchical taxonomy. How do I know the depth of each term? I'd like to add some indentation for child-terms (the more ...
1
vote
1answer
230 views

How to add contents of a custom field to a taxonomy term list?

I have a custom taxonomy term of 'artists' which is the artist's last name and a custom field of 'first_name'. To create a list all all artists with both their first name and last name I am using the ...
1
vote
1answer
269 views

Get posts inside Get terms problem

i have a get_terms which loads correctly. inside of it i have used get_posts. then using get posts i am trying to get each post tags (and count <= not currently inside this script) <?php ...
1
vote
2answers
482 views

get_terms problem : related articles

I'm trying to use get_the_term_list to catch the name of the current taxonomy of the page, and then use it with get_terms and a foreach method, to show the result of all the "elements" from the same ...
1
vote
1answer
39 views

Get terms from posts submitted within a certain time

I am running a query which pulls out the most popular taxonomy terms (named "cause") from a custom post type (named "reasons") and I am ordering them by most popular. However, I need to limit the ...
1
vote
2answers
2k views

Get value in custom field with taxonomy

I have custom field my_cf for Taxonomy/Term. How can I get and output value with custom field for taxonomy/term? I've tried using: $variable = get_field('my_cf', 'basic'); echo $variable; ...
1
vote
1answer
131 views

PHP Code to Display Term URL & Name of a Post Under a Custom Post Type

I am featuring a post in my footer(outside the loop) from a custom post type and am using Advanced Custom Fields plugin to do so. This is the code I am using: <h5>Featured Movie</h5> ...
1
vote
2answers
425 views

get_terms that have custom sticky field checked

I was able to add a extra custom field, named sticky, to a custom taxonomy, using the wp taxonomy meta plugin, like this: function YOUR_PREFIX_register_taxonomy_meta_boxes() { // Make sure ...
1
vote
0answers
69 views

Custom taxonomy widget in admin area

I have a custom taxonomy set up on a custom post type and the box it uses is the same as categories, except I wanted to make it easily searchable using a filter script and then also allow the user to ...
1
vote
0answers
592 views

When using the get_terms and trying to order the terms using the 'order' and/or 'orderby' does not work

does this code really get you the categories in the order you want? $categories = get_terms( 'category', 'order=ASC' ); echo "<pre>"; var_dump($categories); for me, it does not. In fact, ...
1
vote
1answer
252 views

How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?

I'm trying to write a class that would allow for easy removal of all plugin-related data when the plugin is uninstalled. Specifically, I want it to remove plugin options, custom post type entries, and ...
1
vote
2answers
285 views

get_terms on save_post hook

Usually, if I want to check for some attribute of the post I'm about to publish, I will check like this: $post_title = $_POST['post_title']; post_title is the name of the title field in the edit ...
1
vote
3answers
406 views

Show only the grandchildren (using get_terms)

I'm working with a hierarchical taxonomy (named "world") that has 3 levels to it (Regions > Countries > Indigenous Peoples). At the moment I'm using a modified version of this code to paginate ...
1
vote
1answer
502 views

get_terms - name__like a number

Using Get Terms with the argument of 'name__like', how do i return all results that start with any number? I've tried: $feats = get_terms( 'movies', array('name__like' => '1', 'name__like' => ...