0

Currently i am displaying a list of my custom taxonomy (contenttags). These are displayed in a list using the code below, which then displays the posts under that taxonomy.

<?php

$taxonomy = 'contenttags';
$terms = get_terms($taxonomy); // Get all terms of a taxonomy

if ( $terms && !is_wp_error( $terms ) ) :
?>
    <ul>
        <?php foreach ( $terms as $term ) { ?>
            <li><a href="<?php echo get_term_link($term->slug, $taxonomy); ?>"><?php echo $term->name; ?></a></li>
        <?php } ?>
    </ul>
<?php endif;?>

Instead of only being able to select a single term, i want it to be a form where the user can select as many of these terms as they want and hit "filter" for it to return posts for all of those taxonomy terms.

Any ideas how to do this as i have looked everywhere!

1 Answer 1

1

at the simplest level, you could put the options in a select list which would allow a user to ctrl + click to select multiple terms for your form submission. (For something fancier, use javascript/jquery/etc)

You can then write a return function that uses wp_query to filter on the terms (you didn't specify if you were only looking for posts that have ALL of these terms associated with them, or at least one of them). See: http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.