get_terms custom order

This can be easily done with your own custom function. What you want to do here is, get your object from get_terms() which will hold your term objects, check if your unique key is set as a parameter and then according to that, remove that key/pair and add it to the back Now, lets put … Read more

How to handle “the_terms” inside loop

To answer your first question What is the difference between those functions get_terms() returns an array of terms objects that belongs to a specific taxonomy get_the_terms() returns an array of terms belonging to a post the_terms() displays an HTML formatting string of term names belonging to a post Because you need your terms not hyperlinked … Read more

WP_Query use for a filter with multiple Taxonomies and Terms

Try this way: $args = array( ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_status’ => ‘publish’ ); if ( isset( $_POST[‘typefilter’] ) && $_POST[‘typefilter’] !== ” ) { $args[‘post_type’] = ‘post_type_x’; $args[‘tax_query’][0][‘taxonomy’] = ‘type_emp’; $args[‘tax_query’][0][‘field’] = ‘id’; $args[‘tax_query’][0][‘terms’] = $_POST[‘typefilter’]; $args[‘tax_query’][0][‘operator’] = ‘IN’; } if ( $_POST[‘typefilter’] == ”) { $args[‘post_type’] = ‘post_type_x’; } // If … Read more

deleting terms programmatically

You can use below to assign all posts to another term during deletion mentioned on same page.. “The $args ‘force_default’ will force the term supplied as default to be assigned even if the object was not going to be termless.” Other wise if there was only one term attached with post, post becomes term less.

get_terms with more than x post count

Give: $terms = get_terms(“my_taxonomy”); $count = count($terms); if ( $count > 0 ){ echo “<ul>”; foreach ( $terms as $term ) { if ($term->count > 2) { echo “<li>” . $term->name . “</li>”; } } echo “</ul>”; } a shot. It will grab all the terms and then run a check to see if the … Read more