I have implemented a custom post type called "Portfolio" and I have included the taxonomy: category with 3 categories: Category1, Category2 & Category3

I have created a filter form to filter posts based on category as follows at the top of my archive-portfolio.php file:

    $terms = get_terms([
        'taxonomy' => 'category'
    foreach ($terms as $term) : ?>
            <input type="checkbox"
                   value="<?= $term->slug ?>"
                   <?= checked( isset($_GET['category']) && in_array($term->slug, $_GET['category']) )?>
            <?= $term->name ?>
    <?php endforeach; ?>

This successfully displays all 3 categories correctly as selectable checkboxes and when I select one, it reloads the page and the option is selected (so the value is being passed to the page) BUT, the results are not being filtered.

Are there any pre-requisites for this to work?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy