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',
- );
- $search_q = get_query_var( 'sq' );
- $post_type = get_query_var( 'cpt' );
- $type = get_query_var( 'type' );
- $industry = get_query_var( 'industry' );
- $location = get_query_var( 'location' );
- $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 ( $type != 'all' ) {
- $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 ( $industry != 'all' ) {
- $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 ( $location != 'all' ) {
- $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( $ql ) ) {
- if ( $ql != 'all' ) {
- $args['meta_query'] = array(
- array(
- 'key' => 'qualification',
- 'value' => $ql,
- 'compare' => 'LIKE',
- ),
- );
- } else {
- $args['meta_query'] = array(
- array(
- 'key' => 'qualification',
- 'compare' => 'EXISTS',
- ),
- );
- }
- }
- if ( !empty( $experience ) ) {
- if ( $experience != 'all' ) {
- $args['meta_query'] = array(
- array(
- 'key' => 'experience',
- 'value' => strval( $experience ),
- 'compare' => 'LIKE',
- ),
- );
- } else {
- $args['meta_query'] = array(
- array(
- 'key' => 'experience',
- 'compare' => 'EXISTS',
- ),
- );
- }
- }
- $query = new WP_Query( $args );
- if ( $query->have_posts() ) {
- while ( $query->have_posts() ) {
- $query->the_post();
- $job_title = get_the_title();
- $companies_name = get_the_terms( get_the_ID(), 'company_tax' );
- $job_industries = get_the_terms( get_the_ID(), 'industry' );
- $terms_location = get_the_terms( get_the_ID(), 'job-location' );
- $job_types = get_the_terms( get_the_ID(), 'job-type' );
- $post_view = get_post_meta( get_the_ID(), 'tie_views', true );
- $metas = get_post_meta( get_the_ID() );
- ?>
- <div class="job-post-single" id="job-post-single" data-ex-id="<?php echo get_the_ID(); ?>" data-type="<?php echo get_query_var( 'type' )[0]; ?>">
- <div class="job-post-single-top">
- <?php foreach ( $companies_name as $company_name ): ?>
- <div class="job-post-single-top-leftbox">
- <?php
- $t_id = $company_name->term_id;
- // $term_meta = get_option( "company_tax_$t_id" );
- $term_meta = get_term_meta( $t_id, 'company_term_meta', true );
- ?>
- <?php
- if ( $term_meta['company_logo'] != NULL ) {
- echo '<img src="' . $term_meta['company_logo'] . '" alt="' . $company_name->name . '">';
- } else {
- echo '<img src="' . get_stylesheet_directory_uri() . '/assets/images/default_company_logo.jpg" alt="' . $company_name->name . '">';
- }
- ?>
- </div>
- <?php endforeach;?>
- <div class="job-post-single-top-righttbox">
- <a href="<?php echo get_the_permalink(); ?>"><h3><?php echo get_the_title(); ?></h3></a>
- <?php foreach ( $companies_name as $company_name ): ?>
- <span class="company_name"><?php echo $company_name->name; ?></span>
- <?php endforeach;?>
- <ul class="skill_list">
- <h4><?php echo esc_html( 'Skills:' ) ?></h4>
- <?php
- $skills_name = get_the_terms( get_the_ID(), 'skills' );
- $i = 0;
- foreach ( $skills_name as $skill_name ):
- if ( $i < 3 ) {
- ?>
- <li><span><?php echo $skill_name->name; ?></span></li>
- <?php $i++;}
- endforeach;?>
- <?php
- $skills_more = get_the_terms( get_the_ID(), 'skills' );
- $skill_more_count = count( $skills_more );
- $skill_more_count = $skill_more_count - 3;
- ?>
- <?php if ( $skill_more_count > 0 ) {?>
- <li class="count"><span><?php echo '+' . $skill_more_count . ' Others'; ?></span></li>
- <?php }?>
- </ul>
- </div>
- </div>
- <div class="job-post-single-middle">
- <ul class="info-list">
- <li><strong><?php echo esc_html( 'Date:' ) ?></strong><?php echo "<span>" . get_the_date( "d " ) . get_the_date( "M" ) . ", " . get_the_date( "Y" ) . "</span>"; ?></li>
- <li class="list-divider">//</li>
- <li><strong><?php echo esc_html( 'Industry:' ) ?></strong><span><?php foreach ( $job_industries as $job_industry ): ?><?php echo $job_industry->name; ?><?php endforeach;?></span></li>
- <li class="list-divider">//</li>
- <li><strong><?php echo esc_html( 'Location:' ) ?></strong><span><?php foreach ( $terms_location as $term_location ): ?><?php echo $term_location->name; ?><?php endforeach;?></span></li>
- <li class="list-divider">/</li>
- <li class="view"><i class="fas fa-chart-area"></i><span><?php if ( $post_view > 0 && $post_view <= 999 ) {echo $post_view;} elseif ( $post_view > 1000 ) {$result = number_format( ( $post_view / 1000 ), 2 ) . 'K';
- echo $result;} else {echo "0";}?></span></li>
- </ul>
- </div>
- <div class="job-post-single-bottom">
- <p>
- <?php
- $excerpt = get_the_excerpt();
- $excerpt = substr( $excerpt, 0, 220 );
- echo $excerpt . '...';
- ?>
- </p>
- </div>
- <?php foreach ( $job_types as $job_type ): ?>
- <?php
- $color_id = $job_type->term_id;
- $color_meta = get_option( "taxonomy_$color_id" );
- ?>
- <div class="job-type-badge">
- <i class="fas fa-heart"></i>
- <span style="border: 2px solid <?php echo $color_meta['job_type_color']; ?>; color: <?php echo $color_meta['job_type_color']; ?>;"><?php echo $job_type->name; ?></span>
- </div>
- <?php endforeach;?>
- <a class="job-single-view" href="<?php echo get_the_permalink(); ?>"><?php echo esc_html( 'View Details' ) ?></a>
- </div>
- <?php
- }
- }
- // echo do_shortcode('[ajax_load_more id="2021911578" container_type="div" css_classes="posts-container" post_type="jobs" scroll="false"]');
- wp_reset_query();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement