Tuesday, September 6, 2022
HomeWordPress DevelopmentFiltering customized put up varieties utilizing class taxonomy

Filtering customized put up varieties utilizing class taxonomy


I’ve applied a customized put up sort known as “Portfolio” and I’ve included the taxonomy: class with 3 classes: Category1, Category2 & Category3

I’ve created a filter type to filter posts based mostly on class as follows on the high of my archive-portfolio.php file:

<type>
    
    <?php 
    $phrases = get_terms([
        'taxonomy' => 'category'
    ]);
    
    foreach ($phrases as $time period) : ?>
        <label>
            <enter sort="checkbox"
                   title="class[]"
                   worth="<?= $term->slug ?>"
                   <?= checked( isset($_GET['category']) && in_array($term->slug, $_GET['category']) )?>
                   onClick="this.type.submit()"/>
            
            <?= $term->title ?>
        </label>
    
    <?php endforeach; ?>
    
</type>

This efficiently shows all 3 classes accurately as selectable checkboxes and after I choose one, it reloads the web page and the choice is chosen (so the worth is being handed to the web page) BUT, the outcomes aren’t being filtered.

Are there any pre-requisites for this to work?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments