Display Custom Post Type Based on Taxonomy With WP_Query()
Display Custom Post Type Based on Taxonomy With WP_Query()
Display Custom Post Type Based on Taxonomy With WP_Query()
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
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
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
Taxonomy.php inheriting first post
To show all the Products, I’ve created taxonomy-activity.php which already shows all the products that have an activity taxonomy. That’s not what taxonomy-activity.php is for. That template is the template that is used for displaying posts for each activity taxonomy term. So if you view Museum activity, that template will be used to display all … Read more
$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
Get custom taxonomy terms that contain posts that have another taxonomy term
Your first section of code is correct. This means that if it doesn’t output anything, something else is going on and you need to debug your own code to figure out why that is. A good start is to validate that things you think are true are actually true, to look at raw data, and … Read more
add pagination in wordpress page template