Home / Admin / Blog filter
Duplicate Snippet

Embed Snippet on Your Site

Blog filter

Add a filter for blogs

Code Preview
php
<?php
<form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">
    <?php
        if( $terms = get_terms( array( 'taxonomy' => 'category', 'orderby' => 'name' ) ) ) : 
            echo '<select name="categoryfilter"><option>Select category...</option>';
            foreach ( $terms as $term ) :
                echo '<option value="' . $term->term_id . '">' . $term->name . '</option>'; 
            endforeach;
            echo '</select>';
        endif;
    ?>
    <input type="hidden" name="action" value="myfilter">
    <button>Apply filter</button>
</form>

Comments

Add a Comment