Home Forums General Issues How to filter taxonomy terms?


How to filter taxonomy terms?

  • My taxonomy uses a checkbox field. The checkbox field has 5 choices which are: romance, action, adventure, sci-fi & drama. Now I want to create a page that will list taxonomy terms that have ticked checkbox action. How can I do this?

  • Hi @ruriko,

    Thanks for the post.

    I am not sure I have clearly understood the use case, but if you want to list the Taxonomy terms, you can add the following snippet to your template:

    //Get and loop over multiple selected term objects
    $terms = get_field('taxonomy_field_name');
    if( $terms ): ?>
    	<?php foreach( $terms as $term ): ?>
    		<h2><?php echo $term->name; ?></h2>
    		<p><?php echo $term->description; ?></p>
    		<a href="<?php echo get_term_link( $term ); ?>">View all '<?php echo $term->name; ?>' posts</a>
    	<?php endforeach; ?>
    <?php endif; ?>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘How to filter taxonomy terms?’ is closed to new replies.