New answers tagged

0

If you just need IDs, get_ancestors will return an array of parents for any type of object: $term_id = 21; $ancestors = get_ancestors( $term_id, 'location' );


0

I use CMB2 to set up custom fields, and the logic is not so different from ACF in many cases. For my specific use case I've created a very simple but flexible function in order to make a few checks for the taxonomy before displaying the custom field value. Considering one have created a custom field named my_cf for let's say a taxonomy named basic as per ...


0

If you are missing terms, maybe try to show all terms, event those that are not assigned to a post. By default, wordpress does not get terms that are not in a post. get_terms($taxonomy, array('hide_empty' => false));


2

get_terms() doesn't have built-in feature that excludes draft posts because it keeps track of only total posts term is attached to. I made a quick search and found this snippet but be warned: It affects all get_terms() functions on your site (I excluded admin area) There's a SQL query in foreach loop - it will affect performance More terms returned == ...


0

Instead of trying to do this through the orderby parameter, I went a different direction. Logically, the orderby parameter above only applies to the posts within each grouping, not the taxonomy term grouping itself so it won't work for this. What I ended up doing was adding 01, 02, 03, etc. to the taxonomy term name itself, then stripped that out using ...


0

Here is solution, split in arrays: <?php foreach (array_chunk(get_terms( 'razotajs', 'orderby=count&order=DESC&hide_empty=0&parent=0' ), 6, true) as $array) { echo '<div class="logo_sets">'; foreach($array as $cat) { ?> <a href="<?php ...



Top 50 recent answers are included