Displaying dynamic taxonomy term on category post template
-
Hello!
The challenge: to display 2 posts pulled from the post taxonomy ‘organizations’ in the preceding post. The main post taxonomy ‘organizations’ has a term of ‘x’. Then display 2 posts with the term ‘x’. The code below does this but using the term is static. Not so good for a template.
<?php $organizations_query = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => 2, 'tax_query' => array( array( 'taxonomy' => 'organizations', 'field' => 'slug', 'terms' => 'x' )) )); ?> <?php if ( $organizations_query->have_posts() ): ?> <ul><?php while ( $organizations_query->have_posts() ) : $organizations_query->the_post(); ?> <li><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></li> <?php endwhile; ?></ul> <?php endif; ?>
In the code queries from ‘organizations’ and displays posts with the term ‘x’. How do I pull a dynamic term from ‘organizations’? I’ve read the codex, but having trouble putting together the pieces.
Thanks for the help,
Graeme
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Displaying dynamic taxonomy term on category post template’ is closed to new replies.