The get-terms tag has no wiki summary.
5
votes
2answers
572 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
2answers
1k 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 ...
4
votes
1answer
124 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
487 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
2answers
1k 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 ...
2
votes
1answer
2k 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
2answers
537 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 ...
2
votes
1answer
126 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
271 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, ...
2
votes
1answer
32 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
0answers
100 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
2answers
5k 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' ...
1
vote
2answers
106 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
2answers
58 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
116 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
287 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
61 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
77 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
142 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
155 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
1answer
76 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). ...
1
vote
2answers
394 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
0answers
64 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
110 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
64 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
1answer
183 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
226 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' => ...
0
votes
1answer
156 views
Taxonomy order exception for specific term
I want to make an exception for my custom taxonomy order. Sometimes you need to put "Other" option as last option but when calling taxonomies with "orderby=name", sadly "Other" term is not listing as ...
0
votes
2answers
1k views
get_terms of post->id
I need a way to use get_terms and have it only grab the taxonomies of the current page. Example http://sitename.com/genre/hip_hop would only grab the taxonomies that also have the hip hop genre ...
0
votes
1answer
137 views
Is it possible to get_terms by author?
I get terms from all my posts with get_terms,
$tags = get_terms( 'mytags', '&number=5&orderby=date&order=desc&hide_empty=1' );
foreach ( $tags as $tag ) {
echo '<a ...
0
votes
1answer
23 views
get_term_link not working
I am trying to use the below code snippet to display an image and then wrap it in a link to a specific term archive page. In this case, I have a custom taxonomy (Series) with a few different terms. ...
0
votes
1answer
52 views
tax_query in get_posts() not working?
I'm trying to print out all the posts within every taxonomy for a custom post type called product (jigoshop products). So i get all of the taxonomies using $cats = get_terms('product_cat');, then i ...
0
votes
2answers
1k views
Advanced custom fields - taxonomy terms images
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 ...
0
votes
2answers
234 views
get_terms() for custom taxonomy related to another taxonomy
I have this weird thing to do and I have no idea how to do it. Ok, so:
I have two custom taxonomies: collections and categories (both are prefixed, but for the sake of simplicity, I'll use these ...
0
votes
2answers
176 views
get_the_terms - but only show 4 Posts
I am using this code to load related posts with a custom taxonomy term slug:
<?php
global $post;
$terms = get_the_terms( $post->ID , 'topics', 'string');
$do_not_duplicate[] = $post->ID;
...
0
votes
2answers
176 views
How can I get category ID by category name?
I have a few categories with the same name [some of them are sub-categories]. And I want to get an array of ID's for certain cattegory name.
I tried this:
$term = get_term_by('name', $cat_name, ...
0
votes
2answers
71 views
How do I print a term list but alter the link text?
I have a long list of taxonomy terms that all look like City-ST-Zip, ie: Phoenix-AZ-85043 or San-Diego-CA-92037
How do I print the list of terms so that the link URL remains intact but the link text ...
0
votes
1answer
55 views
How to break up php code to avoid echo
I have this php code I am using to list all post (titles) with the taxonomy categories names, and its working fine however I will like to break it up and avoid using echo within the php code so that I ...
0
votes
1answer
36 views
Retrieve Custom Taxonomies with Description and Slug
I've been looking to grab a list of custom taxonomies for a custom post type with the titles, descriptions and tag but have not been able to progress or find anything helpful.
Breakdown:
I have ...
0
votes
1answer
33 views
Problem retriving the post type category
I have a small isuue, this code retrive me the parent categories from a post type.
The post_type is : serial
The taxonomy is : seriale
<?php
$terms = get_terms('seriale','child_of=668');foreach ...
0
votes
1answer
282 views
Display custom taxonomy attached to the post on post single page
I need to display the first custom taxonomy attached to the post on post single page. The custom taxonomy is similar to category attached to the posts. I need to display the first custom taxonomy with ...
0
votes
2answers
74 views
PHP displaying wrong custom taxonomy images
I'm using the Taxonomy Images plugin to try to pull in the category images for custom categories on a page that displays all the categories my site has. For some reason, this code outputs the correct ...
0
votes
3answers
158 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 ...
0
votes
1answer
320 views
How to get the top most term (top ancestor) of a custom taxonomy child term?
I need to get the topmost term (top level ancestor) of a taxonomy term.
Suppose the following term hierarchy:
North America
United States
New York
New York ...
0
votes
1answer
95 views
Unable to get the Parent Custom Taxonomy Terms
I am unable to get the Parent Taxonomy Terms here is the code i am writing
$myterms = get_terms( 'iqvis_event_category', array( 'parent' => 0 ) );
echo '<pre>';
print_r($myterms);
echo ...
0
votes
1answer
132 views
term_exists returns NULL
According to the codex ( http://codex.wordpress.org/Function_Reference/term_exists ), term_exists returns some mixed results but not NULL. In my case, I'm getting NULL, what am I doing wrong?
In ...
0
votes
1answer
134 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 ...
0
votes
2answers
1k views
Get Current Custom Taxonomy ID by Post ID
If I know the current post id that i have in the variable $pid
I use $terms = get_the_terms($pid, 'custom_category');
How do I get just the term id/term_taxonomy_id
if I var_dump $terms I see what ...
0
votes
1answer
266 views
How to check if a term is parent to another?
I have made a product page. Wich lists all products site.com/products. At the product page there is a navigation wich lists all the terms in the taxonomy 'kategori'. The taxonomy is set to ...
0
votes
1answer
154 views
Ordering taxonomy output in this function
I found (googled) this function which performs almost exactly as I need. Creating a link text structure (breadcrumb) of terms for a CPT i.e. Parent Category -> Child Category -> Grand Child Category
...
