archive-program.php WP_MediaQuery @function.php file

//Query For Archive-Event.php Page Start
function custom_event_adjust_queries($query){

    //wpquery for Event archive page
    //if only is NOT Admin And Only On archive-event.php page And Only for the event $query
    if (!is_admin() AND is_post_type_archive('event') AND $query->is_main_query()) {
        $today = date('Ymd');
        $query->set('meta_key', 'event_date');
        $query->set('orderby', 'meta_value');
        $query->set('order', 'ASC');
        $query->set('meta_query', array(
            array(
              'key' => 'event_date',
              'compare' => '>=',
              'value' => $today,
              'type' => 'numeric'
            )
          ));
    }

    //wpquery for Programs archive page
    if(!is_admin() AND is_post_type_archive('event') AND $query->is_main_query()) {
        
        $query->set('orderby', 'title');
        $query->set('order', 'ASC');
        $query->set('post_per_page', -1);//Displays all

    }


}
//Trigger Function 
add_action('pre_get_posts', 'custom_event_adjust_queries');
//Query For Archive-Event.php Page End

Scroll to Top