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.

Return category slug / title from category ID

get_category will return all the information you need for both cases. $catinfo = get_category(get_field(‘category_test’)); From the Codex, that will give you (sample data obviously): stdClass Object ( [term_id] => 85 [name] => Category Name [slug] => category-name [term_group] => 0 [term_taxonomy_id] => 85 [taxonomy] => category Return category slug / title from category ID => … Read more

How do I get taxonomy terms by ID in a specific order

get_terms does not support a post__in argument and I don’t see any other argument that will let you force an order. You can, however, accomplish this with one fof at least two filters: function gto_forced_order($orderby) { $orderby = “FIELD(t.term_id,5,1,4)”; return $orderby; } add_filter(‘get_terms_orderby’,’gto_forced_order’); $terms = get_terms(‘category’); var_dump($terms); Or… function gto_forced_order($pieces) { $pieces[‘orderby’] = “ORDER BY … Read more

Filtering posts by multiple taxonomies

First off, you should be using WP_Query vs query_posts. Have a look at the Taxonomy Parameters. Mainly tax_query and relation. // Repost from link above $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘movie_genre’, ‘field’ => ‘slug’, ‘terms’ => array( ‘action’, ‘comedy’ ) ), array( ‘taxonomy’ => ‘actor’, … Read more