Get category

<?php 
$args = array(
    'post_type' => 'post',
    'posts_per_page' => 3,
    'offset' => 5,
    'post_status' => 'publish',
    'orderby'     => 'publish_date', 
    'order'       => 'DESC'        
  );

  $wp_querys = new WP_Query($args); ?>

<div id="Plywood" class="tabcontent"> 
    <?php 
          $args = array(
            'posts_per_page'   => -1,
            'post_type'        => 'restaurant-menu',
            'tax_query' => array(
                        array(
                            'taxonomy' => 'restaurant_category',
                            'field' => 'term_id',
                            'terms' => '7',
                        )
                    )
        );

      $wp_querys = new WP_Query($args);

      if ( $wp_querys->have_posts() ) :
      while ( $wp_querys->have_posts() ) : $wp_querys->the_post();  
          ?>
          <div class="col-sm-6 test">
          <h3 class="rq-listing-title">
            <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
                     <?php the_post_thumbnail() 
                     ?>
                    
                </div>
      <?php 
      endwhile;
      endif; 
      ?>
</div>
******************************************
<?php
		if( $terms = get_terms( array( 'taxonomy' => 'category', 'orderby' => 'name' ) ) ) : 
 
			echo '<select name="categoryfilter"><option value="">Select category...</option>';
			foreach ( $terms as $term ) :
				echo '<option value="' . $term->term_id . '">' . $term->name . '</option>'; // ID of the category as the value of an option
			endforeach;
			echo '</select>';
		endif;
	?>

Leave a comment