Guest User

Untitled

a guest
Sep 15th, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">
  2.             <?php
  3.             if( $terms = get_terms( array(
  4.                 'taxonomy' => 'category', // to make it simple I use default categories
  5.                 'orderby' => 'name'
  6.             ) ) ) :
  7.  
  8.                 echo '<select name="categoryfilter">';
  9.                 echo '<option name="all" value="">Все категории</option>';
  10.  
  11.                 foreach ( $terms as $term ) :
  12.                     echo '<option name="'. $term->name .'" value="' . $term->term_id . '">' . $term->name . '</option>'; // ID of the category as an option value
  13.                 endforeach;
  14.                 echo '</select>';
  15.             endif;
  16.             ?>
  17.  
  18.             <select name="orderby" id="orderby">
  19.                 <option
  20.                     value="date"
  21.                     <?php echo selected($_GET['orderby'] ?? '', 'date'); ?>
  22.                 >
  23.                     По новизне
  24.                 </option>
  25.                 <option
  26.                     value="down"
  27.                     <?php echo selected($_GET['orderby'] ?? '', 'down'); ?>
  28.                 >
  29.                     По убыванию
  30.                 </option>
  31.                 <option
  32.                     value="up"
  33.                     <?php echo selected($_GET['orderby'] ?? '', 'up'); ?>
  34.                 >
  35.                     По возрастанию
  36.                 </option>
  37.             </select>
  38.  
  39.             <input
  40.                     id="order"
  41.                     type="hidden"
  42.                     name="order"
  43.                     value="<?php echo (isset($_GET['order']) && $_GET['order'] == 'ASC') ? 'ASC' : 'DESC'; ?>"
  44.             >
  45.  
  46.             <input type="submit" value="Применить">
  47.         </form>
Add Comment
Please, Sign In to add comment