How to custom Query Loop…?
-
I would like to output topics with multiple tags.
For that, I wrote the following code, but it did not work as I expected.
<section class="fluits"> <?php $args_fluits = array( 'post_type' => 'topic', 'tax_query' => array( array( 'taxonomy' => 'tag_fluits', 'field' => 'term_id', 'terms' => array( 11, 22 ), ), ), ); $query_fluits = new WP_Query( $args_fluits ); ?> <?php if ( bbp_has_topics( $query_fluits ) ) : ?> <?php bbp_get_template_part( 'pagination', 'topics' ); ?> <?php bbp_get_template_part( 'loop', 'topics' ); ?> <?php bbp_get_template_part( 'pagination', 'topics' ); ?> <?php else : ?> <?php bbp_get_template_part( 'feedback', 'no-topics' ); ?> <?php endif; ?> </section> <section class="vegetables"> <?php $args_vegetables = array( 'post_type' => 'topic', 'tax_query' => array( array( 'taxonomy' => 'tag_vegetables', 'field' => 'term_id', 'terms' => array( 33, 44 ), ), ), ); $query_vegetables = new WP_Query( $args_vegetables ); ?> <?php if ( bbp_has_topics( $query_vegetables ) ) : ?> <?php bbp_get_template_part( 'pagination', 'topics' ); ?> <?php bbp_get_template_part( 'loop', 'topics' ); ?> <?php bbp_get_template_part( 'pagination', 'topics' ); ?> <?php else : ?> <?php bbp_get_template_part( 'feedback', 'no-topics' ); ?> <?php endif; ?> </section>
Any hints or different args to use to achieve this?
Thanks.
- You must be logged in to reply to this topic.