Articles of get terms

More efficient way to list posts by category

This question already has an answer here: Get all categories and posts in those categories 6 answers

Display empty custom taxonomies differently than with one with posts

I’m trying to display all of my custom taxonomies using get_terms. This part is fine. But I’d like to display the taxonomies that have zero posts attached to them slightly differently. Here’s what I have so far: Can somebody point me in the right direction? Many thanks, Mitch

How can I get 3 different taxonomy type terms in a div class element?

I have this situation where I need to filter specific post type posts by its taxonomies (there 3 different ones) and since I am using Isotope, I need them in my class element. I already made it work with one and I believe I took the ‘long’ road. I dont really work that much with […]

CTP – check for value inside objects

I have registered a CTP which can add a new plant and user can tick which months it can be planted (february, march and april for example). Now, I need to display it on the page but with all months listed starting from the first one. For example january: no, february: yes, march: yes, april: […]

Getting Category Children

i have a problem understanding the get_terms function All i want is getting all the children of specific category so that it can be listed. But i don’t really know how the $args works. So with this get_terms(category, $args); I tried to use the child_of $args = array( ‘child_of’ => 0, ‘childless’ => false, ); […]

Group child category IDs based on their parent category

I have IDs for my child categories, 11,14,21,35,38,39, where these all are various child categories from their main category: Parent category 1 has: 11,14 Parent category 2 has: 21 Parent category 3 has: 35,38,39 How can I group my child IDs as per their parent category, like below? array( 1 => array ( 11,14 ), […]

Add arguments to get_the_terms for custom post types

When using get_the_terms to retrieve terms within a taxonomy for a custom post type you can’t pass arguments, like so: function custom_cat_function() { global $post; $args = array( ‘orderby’ => ‘ID’, ‘order’ => ‘ASC’, ); $terms = get_the_terms($post->id, ‘category’, $args); $count = count( $terms ); if ( $count > 0 ) { foreach ( $terms […]

Create a a form for custom taxonomy terms

Currently i am displaying a list of my custom taxonomy (contenttags). These are displayed in a list using the code below, which then displays the posts under that taxonomy. <?php $taxonomy = ‘contenttags’; $terms = get_terms($taxonomy); // Get all terms of a taxonomy if ( $terms && !is_wp_error( $terms ) ) : ?> <ul> <?php […]

How to display taxonomy terms the way they are hierarchical

Reading Kaiser’s query and Scribu’s answer I’m now in an ocean of no shore. I made a custom taxonomy, where I want to show the terms as per their hierarchy, like below: Level 0 — Level 1 — Level 2 —- Level 3 — Level 2 —- Level 3 —- Level 3 — Level 1 […]

Ordering get_terms with ACF not displaying all terms

I’m making a shortcode to return all the terms in this taxonomy. The terms are sorted with krsort by the custom field ‘height’ made from ACF. I’m following this answer from here. The problem is it’s only displaying 8 terms and there’s 15 in total. All of these terms have the custom field filled out […]