title: How to categorize wordpress custom post for upcoming event and past event
body: <p>I have created a custom post 'webinar' and now i want to show upcoming webinar on a separate section and past webinar on separate section by using wordpress categories.</p>
  <p>here is my custom post type:-</p>
  <pre><code>// webinar post type
      $labels = array(
              'name'               =&gt; _x( 'Webinars', 'post type general name', 'impactqa' ),
              'singular_name'      =&gt; _x( 'Webinar', 'post type singular name', 'impactqa' ),
              'menu_name'          =&gt; _x( 'Webinars', 'admin menu', 'impactqa' ),
              'name_admin_bar'     =&gt; _x( 'Webinar', 'add new on admin bar', 'impactqa' ),
              'add_new'            =&gt; _x( 'Add New', 'Webinar', 'impactqa' ),
              'add_new_item'       =&gt; __( 'Add New Webinar', 'impactqa' ),
              'new_item'           =&gt; __( 'New Webinar', 'impactqa' ),
              'edit_item'          =&gt; __( 'Edit Webinar', 'impactqa' ),
              'view_item'          =&gt; __( 'View Webinar', 'impactqa' ),
              'all_items'          =&gt; __( 'All Webinars', 'impactqa' ),
              'search_items'       =&gt; __( 'Search Webinars', 'impactqa' ),
              'parent_item_colon'  =&gt; __( 'Parent Webinars:', 'impactqa' ),
              'not_found'          =&gt; __( 'No Webinars found.', 'impactqa' ),
              'not_found_in_trash' =&gt; __( 'No Webinars found in Trash.', 'impactqa' )
          );
  
          $args = array(
              'labels'             =&gt; $labels,
                      'description'        =&gt; __( 'Description.', 'impactqa' ),
              'public'             =&gt; true,
              'publicly_queryable' =&gt; true,
              'show_ui'            =&gt; true,
              'show_in_menu'       =&gt; true,
              'query_var'          =&gt; true,
              'rewrite'            =&gt; array( 'slug' =&gt; 'webinar', 'with_front' =&gt; false ),
              'capability_type'    =&gt; 'post',
              'has_archive'        =&gt; true,
              'hierarchical'       =&gt; false,
              'menu_position'      =&gt; null,
              'supports'           =&gt; array( 'title', 'editor', 'author', 'thumbnail', 'excerpt' )
          );
  
          register_post_type( 'webinar', $args );
  
          $labels = array(
          'name'              =&gt; _x( 'Webinar Categories', 'impactqa' ),
          'singular_name'     =&gt; _x( 'Webinar Category', 'impactqa' ),
          'search_items'      =&gt; __( 'Search Webinar Categories' ),
          'all_items'         =&gt; __( 'All Webinar Categories' ),
          'parent_item'       =&gt; __( 'Parent Webinar Category' ),
          'parent_item_colon' =&gt; __( 'Parent Webinar Category:' ),
          'edit_item'         =&gt; __( 'Edit Webinar Category' ), 
          'update_item'       =&gt; __( 'Update Webinar Category' ),
          'add_new_item'      =&gt; __( 'Add New Webinar Category' ),
          'new_item_name'     =&gt; __( 'New Webinar Category' ),
          'menu_name'         =&gt; __( 'Webinar Categories' ),
      );
           $args = array(
          'labels' =&gt; $labels,
          'rewrite'   =&gt; array( 'with_front'    =&gt; false ),
          'hierarchical' =&gt; true,
      );
      register_taxonomy( 'webinar_category', 'webinar', $args );
  </code></pre>
  <p>and here is my template code:-</p>
  <pre><code> &lt;section class=&quot;section-padding&quot;&gt;
      &lt;div class=&quot;container&quot;&gt;
          &lt;div class=&quot;row&quot;&gt;
              &lt;div class=&quot;col-md-12 text-center&quot;&gt;
                  &lt;h2 class=&quot;pb-30&quot;&gt;Upcoming Webinars&lt;/h2&gt;
                  &lt;hr class=&quot;serprate-line&quot; style=&quot;background-image: linear-gradient(to right, transparent, grey, transparent);&quot;&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/section&gt;
  &lt;section class=&quot;page-wrapper&quot;&gt;
      &lt;div class=&quot;container&quot;&gt;
          &lt;div class=&quot;row justify-content-center&quot;&gt;
  &lt;?php
      $query = new WP_Query(
                  array(
                      'post_type' =&gt; 'webinar', 
                      'post_status' =&gt; 'publish', 
                      'order' =&gt; 'ASC',
                      
                      )
                  );
          if ($query-&gt;have_posts()) :
                  while ($query-&gt;have_posts()) : $query-&gt;the_post();
                      $date_posted = get_field('date_posted');
                      $date_posted = strtotime($date_posted); 
                      $date_current = date('Ymd'); // the date format should be same as the date format on $date_posted
                      $date_current = strtotime($date_current);
                      if ($date_posted &gt;= $date_current) : // compare date
                      $featured_img_url = get_the_post_thumbnail_url(get_the_ID(), 'full');?&gt;
                      &lt;div class=&quot;col-lg-4 col-md-6&quot;&gt;
                          &lt;div class=&quot;webinar-wrapper&quot;&gt;
                              &lt;a href=&quot;&lt;?php echo get_the_permalink(); ?&gt;&quot;&gt;&lt;img src=&quot;&lt;?php echo $featured_img_url; ?&gt;&quot;&gt;&lt;/a&gt;
                              &lt;div class=&quot;webinar-title&quot;&gt;
                                  &lt;h5&gt;&lt;a href=&quot;&quot;&gt;&lt;?php echo get_field('webinar_heading'); ?&gt;&lt;/a&gt;&lt;/h5&gt;
                              &lt;/div&gt;
                              &lt;span class=&quot;pDate&quot;&gt;&lt;?php echo get_the_date('d M, Y'); ?&gt;&lt;/span&gt; &lt;!-- &lt;span class=&quot;pipe&quot;&gt;|&lt;/span&gt; --&gt;
                              &lt;!-- &lt;span class=&quot;pTime&quot;&gt;&lt;?php echo get_the_time(); ?&gt;&lt;/span&gt; --&gt;
                              &lt;!-- &lt;span class=&quot;minRead&quot;&gt;
                                  &lt;?php
                                  $words = str_word_count(get_the_content());
                                  $perMinutes = 200;
                                  $minutes = ceil($words/$perMinutes);
                                  echo $minutes.' MIN';
                                  ?&gt;
                              &lt;/span&gt; --&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  
      &lt;?php
  endif;
       endwhile;
              endif;  ?&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/section&gt;
  
  &lt;section class=&quot;section-padding&quot;&gt;
      &lt;div class=&quot;container&quot;&gt;
          &lt;div class=&quot;row&quot;&gt;
              &lt;div class=&quot;col-md-12 text-center&quot;&gt;
                  &lt;h2 class=&quot;pb-30&quot;&gt;Past Webinars&lt;/h2&gt;
                  &lt;hr class=&quot;serprate-line&quot; style=&quot;background-image: linear-gradient(to right, transparent, grey, transparent);&quot;&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/section&gt;
  
  &lt;section class=&quot;page-wrapper&quot;&gt;
      &lt;div class=&quot;container&quot;&gt;
          &lt;div class=&quot;row justify-content-center&quot;&gt;
  &lt;?php
      $query = new WP_Query(
                  array(
                      'post_type' =&gt; 'webinar', 
                      'post_status' =&gt; 'publish', 
                      'order' =&gt; 'ASC',
                      
                      )
                  );
          if ($query-&gt;have_posts()) :
                  while ($query-&gt;have_posts()) : $query-&gt;the_post();
                      $date_posted = get_field('date_posted');
                      echo $date_posted;
                      $date_posted = strtotime($date_posted); 
                      $date_current = date('Ymd'); // the date format should be same as the date format on $date_posted
                      $date_current = strtotime($date_current);
                      if ($date_posted &lt; $date_current) : // compare date
                      $featured_img_url = get_the_post_thumbnail_url(get_the_ID(), 'full');?&gt;
                      &lt;div class=&quot;col-lg-4 col-md-6&quot;&gt;
                          &lt;div class=&quot;webinar-wrapper&quot;&gt;
                              &lt;a href=&quot;&lt;?php echo get_the_permalink(); ?&gt;&quot;&gt;&lt;img src=&quot;&lt;?php echo $featured_img_url; ?&gt;&quot;&gt;&lt;/a&gt;
                              &lt;div class=&quot;webinar-title&quot;&gt;
                                  &lt;h5&gt;&lt;a href=&quot;&quot;&gt;&lt;?php echo get_field('webinar_heading'); ?&gt;&lt;/a&gt;&lt;/h5&gt;
                              &lt;/div&gt;
                              &lt;span class=&quot;pDate&quot;&gt;&lt;?php echo get_the_date('d M, Y'); ?&gt;&lt;/span&gt; &lt;!-- &lt;span class=&quot;pipe&quot;&gt;|&lt;/span&gt; --&gt;
                              &lt;!-- &lt;span class=&quot;pTime&quot;&gt;&lt;?php echo get_the_time(); ?&gt;&lt;/span&gt; --&gt;
                              &lt;!-- &lt;span class=&quot;minRead&quot;&gt;
                                  &lt;?php
                                  $words = str_word_count(get_the_content());
                                  $perMinutes = 200;
                                  $minutes = ceil($words/$perMinutes);
                                  echo $minutes.' MIN';
                                  ?&gt;
                              &lt;/span&gt; --&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  
      &lt;?php
  endif;
       endwhile;
              endif;  ?&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/section&gt;
  </code></pre>
  <p>Issue- when i puting some events in backend then its showing on past event section and upcoming section is blank.</p>