Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $args = array(
- 'post_type' => 'jobs',
- 'posts_per_page' => 5,
- 'post_status' => 'publish',
- );
- $type = get_query_var( 'type' );
- $industry = get_query_var( 'industry' );
- $location = get_query_var( 'location' );
- $role = get_query_var( 'role' );
- $experience = get_query_var( 'experience' );
- $ql = get_query_var( 'ql' );
- /* if ( !empty( $search_q ) && $post_type == 'jobs' ) {
- $args = array(
- 's' => $search_q,
- 'post_type' => 'jobs',
- );
- } */
- if ( !empty( $type ) ) {
- if (!in_array('all', $type) ) {
- $args['tax_query'] = array(
- array(
- 'taxonomy' => 'job-type',
- 'field' => 'slug',
- 'terms' => $type,
- ),
- );
- } else {
- $term_id = [];
- $_terms = get_terms( ['taxonomy' => 'job-type', 'hide_empty' => true] );
- foreach ( $_terms as $_term ) {
- $term_id[] = $_term->term_id;
- }
- $args['tax_query'] = array(
- array(
- 'taxonomy' => 'job-type',
- 'field' => 'term_id',
- 'terms' => $term_id,
- ),
- );
- }
- }
- if ( !empty( $industry ) ) {
- if ( !in_array('all', $industry )) {
- $args['tax_query'] = array(
- array(
- 'taxonomy' => 'industry',
- 'field' => 'slug',
- 'terms' => $industry,
- ),
- );
- } else {
- $term_id = [];
- $_terms = get_terms( ['taxonomy' => 'industry', 'hide_empty' => true] );
- foreach ( $_terms as $_term ) {
- $term_id[] = $_term->term_id;
- }
- $args['tax_query'] = array(
- array(
- 'taxonomy' => 'industry',
- 'field' => 'term_id',
- 'terms' => $term_id,
- ),
- );
- }
- }
- if ( !empty( $location ) ) {
- if ( !in_array('all', $location ) ) {
- $args['tax_query'] = array(
- array(
- 'taxonomy' => 'job-location',
- 'field' => 'slug',
- 'terms' => $location,
- ),
- );
- } else {
- $term_id = [];
- $_terms = get_terms( ['taxonomy' => 'job-location', 'hide_empty' => true] );
- foreach ( $_terms as $_term ) {
- $term_id[] = $_term->term_id;
- }
- $args['tax_query'] = array(
- array(
- 'taxonomy' => 'job-location',
- 'field' => 'term_id',
- 'terms' => $term_id,
- ),
- );
- }
- }
- if ( !empty( $role ) ) {
- if (!in_array('all', $role ) ) {
- $args['tax_query'] = array(
- array(
- 'taxonomy' => 'job-speciality',
- 'field' => 'slug',
- 'terms' => $role,
- ),
- );
- } else {
- $term_id = [];
- $_terms = get_terms( ['taxonomy' => 'job-speciality', 'hide_empty' => true] );
- foreach ( $_terms as $_term ) {
- $term_id[] = $_term->term_id;
- }
- $args['tax_query'] = array(
- array(
- 'taxonomy' => 'job-speciality',
- 'field' => 'term_id',
- 'terms' => $term_id,
- ),
- );
- }
- }
- if ( !empty( $ql ) ) {
- if ( !in_array('all', $ql ) ) {
- $args['meta_query'] = array(
- array(
- 'key' => 'qualification',
- 'value' => $ql,
- 'compare' => 'IN',
- ),
- );
- } else {
- $args['meta_query'] = array(
- array(
- 'key' => 'qualification',
- 'compare' => 'EXISTS',
- ),
- );
- }
- }
- if ( !empty( $experience ) ) {
- if ( !in_array('all', $experience ) ) {
- $args['meta_query'] = array(
- array(
- 'key' => 'experience',
- 'value' => strval( $experience ),
- 'compare' => 'IN',
- ),
- );
- } else {
- $args['meta_query'] = array(
- array(
- 'key' => 'experience',
- 'compare' => 'EXISTS',
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement