Can’t display posts by filtering categories using isotope.js

Can you try: <?php if (have_posts()): ?> <?php while (have_posts()): the_post(); ?> <?php $categories = get_the_category(); $listCategories = []; foreach ($categories as $category) { $listCategories[] = $category->slug; } ?> <!– Isotope Grid-Item –> <div class=”col-md-3 col-sm-4 col-xs-12 isotope-grid-item <?php echo implode(‘ ‘, $listCategories); ?>” data-category=”<?php echo implode(‘,’, $listCategories); ?>”> <div class=”isotope-item”> <a href=”#”> <div class=”isotope-feature-image”><?php … Read more

Order get_terms by count using a custom taxonomy hierarchy

Don’t know if it’s the best solution but I ended up using a custom query to show all categories ordered by count. $cats = $wpdb->get_results(” select tt.term_id, count, name, slug from “.$wpdb->prefix.”term_taxonomy as tt inner join “.$wpdb->prefix.”terms as terms on tt.term_id = terms.term_id where taxonomy = ‘product_cat’ order by count desc limit 10 “); echo … Read more

Replace deprecated get_category_children code with get_terms

Yes, get_category_children() is indeed deprecated and you should use get_term_children() instead. So with your original code: // You can simply replace this: if (get_category_children($this_category->cat_ID) != “”) // with this: $ids = get_term_children( $this_category->cat_ID, ‘category’ ); if ( ! empty( $ids ) ) And with your second code which uses get_terms(), you can check if the … Read more

Excluded Custom Taxonomy Term Posts Displaying in loop

Try below methods: Try by adding term ID in array like this ‘exclude’=> ’60’ in array If this is not working you can try with below WP_Query loop: $args = array( ‘post_type’ => ‘careers’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘careers_categories’, ‘field’ => ‘term_id’, ‘terms’ => array( 60), ‘operator’ => ‘NOT IN’, … Read more

get taxonomies from terms

After some research I came up with the following // Get the posts in that category with the required tag $args = array( ‘post_type’ => [‘documents’,’news’], ‘fields’ => ‘ids’, // Only get post IDs ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘forms’, ‘field’ => ‘slug’, ‘terms’ => $symbol ) ) ); $posts_array = … Read more

How to list posts by terms

$terms = get_terms(‘CUSTOM_TAXONOMY’, [‘hide_empty’ => true]); foreach( $terms as $term ){ echo ‘<section>’; echo ‘<h1>’ . $term->name . ‘</h1>’; $posts = get_posts([ ‘post_type’ => ‘CUSTOM_POST_TYPE’ ‘tax_query’ => [ [ ‘taxonomy’ => ‘CUSTOM_TAXONOMY’, ‘field’ => ‘term_id’, ‘terms’ => $term->term_id ] ] ]); echo ‘<ul>’; foreach($posts as $post){ echo sprintf(‘<li><a href=”%s”>%s</a></li>’, get_permalink($post), $post->post_title); } echo ‘</ul>’; echo … Read more