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