Get posts by Taxonomy without terms

You may do it by this method. $media_category = get_terms(‘media_category’); foreach($media_category as $cat) { wp_reset_query(); $args = array(‘post_type’ => ‘your_post_type’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘media_category’, ‘field’ => ‘slug’, ‘terms’ => $cat->slug, ), ), ); $loop = new WP_Query($args); if($loop->have_posts()) { // echo $cat->name; while($loop->have_posts()) : $loop->the_post(); echo get_the_title(); endwhile; } }

Having Issue on Passing Variable into HTML Class Tag

Right, that’s because “get_the_term_list” returns an html string of tags… Those won’t work well as class attributes! : ) I suspect what you want is wp_get_post_terms instead: $terms = wp_get_post_terms( get_the_ID(), ‘type’, array(‘fields’ => ‘slugs’) ); // array of term slugs echo ‘<div class=”element-item’.implode(‘ ‘, $terms).'”>’; Hope this helps!

Update table wp_term_taxonomy.count after INSERT INTO via SQL

You can just run the wp_update_term_count_now php function after doing this: https://developer.wordpress.org/reference/functions/wp_update_term_count_now/ Which calls the private _update_post_term_count https://developer.wordpress.org/reference/functions/_update_post_term_count/ If you look at the source of that you will see how term counts are updated (which is done when you save a post on backend): function _update_post_term_count( $terms, $taxonomy ) { global $wpdb; $object_types = (array) … Read more

WordPress Custom Post Type – show only certain posts that have specific taxonomy set

So basically your question can also be put as: show all posts if the post have been assigned any term from taxonomy. SO this code shoudl do : $args = array( ‘post_type’ => ‘food_dish’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘menu’, ‘field’ => ‘name’, ‘terms’ => array(‘premium’, ‘children’, ‘concept’), ), ), ); If you feel … Read more