title: Run Wordpress query on button click
body: <p>Im trying to see the best way to implement this feature. I have events that are shown as long as they are within the date parameters as so:</p>
  
  <pre><code>&lt;?php $args = array(
                      'post_type' =&gt; 'events',
  
                      'orderby'   =&gt; '_cmb_event_date_timestamp',
                      'meta_key'  =&gt; '_cmb_event_date_timestamp',
                      'order'     =&gt; 'ASC',
                      'meta_query' =&gt; array(
                          array( /* Timestamp query to hide old dates */
                              'key' =&gt; '_cmb_event_date_timestamp',
                              'value' =&gt; strtotime('today'),
                              'compare' =&gt; '&gt;'
                          )
                      ),
                  );
                  $q = new WP_Query($args);
                  $loop = new WP_Query( $args );
                  while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); ?&gt;
  </code></pre>
  
  <p>I have two buttons: One saying <code>upcoming events</code> and the other saying <code>past events</code>. 
  I want to run the reverse query <code>'compare' =&gt; '&lt;'</code>  when <code>past events</code> is clicked but I can't see how best to implement this feature. Any suggestions/ways to implement this would be appreciated. I tried reloading using jquery but couldn't get it to work.</p>