Tag Info

New answers tagged

1

I had the same problem and I solved easily. Check this out: Define $taxonomy. It can be the slug of the taxonomy you want to get the data. After doing this, you can simply do this: <?php $postterms = wp_get_post_terms($post->ID, $taxonomy); // get post terms $parentId = $postterms[0]->parent; // get parent term ID ...


1

As I said, this is doable, but we need to do careful planning as this is quite a heavy operation. On my test installation with a post count of just 13 posts, and 3 terms per taxonomy, the db is visited 20 times and the complete operation takes 0.03613 seconds. I have tried a couple of solutions, and this one is by far the fastest. We will look at a ...


0

This is the working code: // latest edition $taxonomies = array( 'jjm_editions' ); $args = array( 'orderby' => 'ID', 'order' => 'DESC', 'hide_empty' => false, 'number' => '1' ); $terms = get_terms($taxonomies, $args); foreach ( $terms as $term ) { $term_link = get_term_link( $term ...


3

If you already have the term, like the term is an actual object you could use $term->parent. Otherwise you can do something like this: $term = get_term($id, 'YOUR_TAXONOMY_HERE'); $termParent = ($term->parent == 0) ? $term : get_term($term->parent, 'YOUR_TAXONOMY_HERE'); The 2nd portion of this is a shorthand if-else, IF it doesn't have a parent, ...


0

check your closing your missing the close. It should be <li><a href=""></a></li>


0

To get children with get_terms() you have two options. You can either use the argument parent, which will only get direct children, so only one level down; or you use child_of, which gets all descendants, meaning until last level down. Both parent and child_of need an integer as value, which would in both cases be the parents ID. Basic code example: ...


0

get_terms does exactly what it says, it retrieves all terms of the specified taxonomy Retrieve the terms in a taxonomy or list of taxonomies. There are a couple of functions that you can make use of here. You nedd to follow the links, each functions is well documented with examples. You just need to choose the one that fits your needs best the_terms ...



Top 50 recent answers are included