Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">
- <?php
- if( $terms = get_terms( array(
- 'taxonomy' => 'category', // to make it simple I use default categories
- 'orderby' => 'name'
- ) ) ) :
- echo '<select name="categoryfilter">';
- echo '<option name="all" value="">Все категории</option>';
- foreach ( $terms as $term ) :
- echo '<option name="'. $term->name .'" value="' . $term->term_id . '">' . $term->name . '</option>'; // ID of the category as an option value
- endforeach;
- echo '</select>';
- endif;
- ?>
- <select name="orderby" id="orderby">
- <option
- value="date"
- <?php echo selected($_GET['orderby'] ?? '', 'date'); ?>
- >
- По новизне
- </option>
- <option
- value="down"
- <?php echo selected($_GET['orderby'] ?? '', 'down'); ?>
- >
- По убыванию
- </option>
- <option
- value="up"
- <?php echo selected($_GET['orderby'] ?? '', 'up'); ?>
- >
- По возрастанию
- </option>
- </select>
- <input
- id="order"
- type="hidden"
- name="order"
- value="<?php echo (isset($_GET['order']) && $_GET['order'] == 'ASC') ? 'ASC' : 'DESC'; ?>"
- >
- <input type="submit" value="Применить">
- </form>
Add Comment
Please, Sign In to add comment