Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $args = array();
- $args['s'] = $_REQUEST['search'];
- $args['tax_query'] = array( 'relation' => 'AND' );
- $args['meta_query'] = array(
- 'relation' => 'OR',
- array(
- array(
- 'key' => 'pt_assessment',
- 'value' => 'rebel',
- 'compare' => 'LIKE'
- ),
- ),
- array( 'relation' => 'AND' ),
- );
- // collect filter data
- // apply post types
- if ( array_key_exists( 'types', $_REQUEST ) && is_array( $_REQUEST['types'] ) && count( $_REQUEST['types'] ) > 0 ) {
- $args['post_type'] = $_REQUEST['types'];
- }
- // apply grade filter (if any)
- if ( array_key_exists('grade', $_POST) && strlen( $_POST['grade'] ) > 0 ) {
- $args['meta_query'][1][] = array(
- 'key' => 'pt_grade_level',
- 'value' => $_POST['grade'],
- 'compare' => '=',
- );
- }
- // apply content area filter (if any)
- if ( array_key_exists('contentArea', $_POST) && strlen( $_POST['contentArea'] ) > 0 ) {
- $args['meta_query'][1][] = array(
- 'key' => 'pt_content_area',
- 'value' => serialize( strval( $_POST['contentArea'] ) ),
- 'compare' => 'LIKE',
- );
- }
- // apply standard filter (if any)
- if ( array_key_exists('standard', $_POST) && strlen( $_POST['standard'] ) > 0 ) {
- $args['meta_query'][1][] = array(
- 'key' => 'pt_standard',
- 'value' => $_POST['standard'],
- 'compare' => '=',
- );
- }
- // apply PD Course taxonomy filter (if any)
- if ( array_key_exists('pdCourse', $_POST) && strlen( $_POST['pdCourse'] ) > 0 ) {
- $args['tax_query'][] = array(
- 'taxonomy' => 'pd_courses',
- 'field' => 'id',
- 'terms' => $_POST['pdCourse'],
- 'operator' => 'IN',
- );
- }
- $loop = new WP_Query( $args );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement