Get assigned post categories
wp_get_post_categories() is only for Core Categories – not custom taxonomies. Try wp_get_post_terms(). 🙂
wp_get_post_categories() is only for Core Categories – not custom taxonomies. Try wp_get_post_terms(). 🙂
get_terms first and only parameter should be an array. docs get_terms([ ‘taxonomy’ => ‘king_blog_category’, ‘hide_empty’ => 0, ‘parent’ => 0 ]);
i got the solution for this add_action(‘user_register’, function ($user_id) { $user_info = get_userdata($user_id); $user_name = $user_info->user_login; wp_insert_term($user_name, ‘user1’, array()); }, 10, 1);
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
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
Product attribute taxonomies are prefixed with pa_, so you can check the taxonomy name for that prefix and skip it if it exists: if ( substr( $taxonomy->name, 0, 3 ) === ‘pa_’ ) { continue; }
You can create taxonomy template like taxonomy-[Your-texonomy].php in your theme folder.
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
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 );
When doing register_taxonomy, set the public parameter of the args argument to false. Most basic example: register_taxonomy( ‘my_tax, ‘post’, [ ‘public’ => false ] );