get current taxonomy post with ajax

//$bkcat = $term->term_id; try to call this via post from ajax where you will pass id of category $args = array( ‘posts_per_page’ => -1, ‘category’ => $bkcat, ‘order’ => ‘ASC’, ‘post_type’ => ‘bk-post’, ‘category_name’ => $bkcat, ); $the_query = new WP_Query($args); if($the_query->have_posts()) { ?> $i = 1; while($the_query->have_posts()) : $the_query->the_post(); $a = $i++; endwhile; } … Read more

Get an array of custom taxonomy with posts inside each items

$terms = get_terms( ‘custom_taxonomy’, array( ‘hide_empty’ => false, )); foreach( $terms as $term ) { $args = [ ‘post_type’ => ‘custom_post_type’, ‘post_status’ => ‘publish’, ‘tax_query’ => [ [ ‘taxonomy’ => ‘custom_taxonomy’, ‘field’ => ‘id’, ‘terms’ => $term->term_id, ] ] ]; $posts = new WP_Query( $args ); $result[ $term->term_id ] = $posts->posts; } In result you … Read more

How to show list of taxonomy terms associated with specific post?

I used following codes and it is working perfectly. <?php $terms = wp_get_post_terms($post->ID, ‘competition’); ?> <?php $count = count($terms); if ( $count > 0 ) { foreach( $terms as $term ) {?> <section class=”achievement-section clearfix”> <?php $counter = 0; ?> <div class=” league-and-season clearfix”> <div class=”honour-league-name”> <?php echo $term->name; ?> </div> <?php $team = get_post_meta( … Read more

Get Taxonomy name from “registered_taxonomy” hook

$args is an array, not an object: function test( $taxonomy, $object_type, $args ) { echo $args[‘name’]; } add_action( ‘registered_taxonomy’, ‘test’, 10, 3 ); EDIT Using the create_term action: function my_create( $term_id, $tt_id, $taxonomy ){ $term = get_term( $term_id, $taxonomy ); echo $term->name; } add_action( ‘create_term’, ‘my_create’, 10, 3 );

Remove Category When Post Transitions from Status Private To Public And has Specific categories already?

Couple of things: You’re not providing a post to check in in_category(). You’re calling wp_remove_object_terms() on $postID, which hasn’t been set. This code should work: function my_remove_category_on_status_change( $new_status, $old_status, $post ) { if ( $old_status == ‘private’ && $new_status=”publish” && in_category( array( ‘1186’, ‘1208’ ), $post ) ) { wp_remove_object_terms( $post->ID, 1186, ‘category’ ); // … Read more

How to display taxonomy term custom meta (using wp_get_object_terms?)?

If those extra fields are saved on Edit User page you should get them with get_user_meta function: $social_twitter_handle = get_user_meta( $curauth->ID, ‘firm_social_twitter_handle’, true ); If those extra fields are attached to each term you can use get_term_meta function: $firm_terms = wp_get_object_terms( $curauth->ID, ‘firm’ ); if ( ! empty( $firm_terms ) ) { if ( ! … Read more