Loop posts based on permalink term

Got it to work with: $queried_object = get_queried_object () ; and ‘terms’ => $queried_object->slug, full code now: <?php $queried_object = get_queried_object () ; $posts = array ( ‘post_type’ => ‘writing’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘type’, ‘field’ => ‘slug’, ‘terms’ => $queried_object->slug, ), ), ); $loop = new WP_Query( $posts ); … Read more

Get posts in taxonomy randomly

You have syntax error in tax_query. ‘tax_query’ => array( array ( ‘taxonomy’ => $term->taxonomy, ‘field’ => ‘term_id’, // this is default value, so can be ommited ‘terms’ => $term->term_id, ) ) As you can read in Codex, possible values for field parameter are: term_id (default), name, slug or term_taxonomy_id. In this question you can read … Read more

WordPress multisite – is it possible to have different taxonomies for each site?

Sure, you can. Each site in multisite is completely independent, so you can have completely different CPTs, taxonomies and… everything. The problem is that if you register the CPT via a plugin, and you enable it in all sites (or network-activate it) and you use the same plugin to register taxonomies, you’ll have same taxonomies … Read more

How to return newly added terms when using wp_set_object_terms

You can add a filter for a specific function call like so: add_filter( ‘set_object_terms’, ‘checkNewTerm’, 10, 6 ); function checkNewTerm( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) { // Do stuff, ie. compare count of $tt_ids and $old_tt_ids } wp_set_object_terms($id, array($migrate_case), ‘pa_case’); remove_filter( ‘set_object_terms’, ‘checkNewTerm’, 10, 6 );