Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Template Name: Search Page Template
- * @link https://codex.wordpress.org/Template_Hierarchy
- * @package essential
- */
- get_header(); ?>
- <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
- <?php
- if( isset( $_GET['location'] ) && isset( $_GET['service'] ) ){
- $location = $_GET['location'];
- $service = $_GET['service'];
- $listing_args = array(
- 'post_type' => 'business',
- 'posts_per_page' => 10,
- 'meta_key' => 'listing_num',
- 'orderby' => 'meta_value_num',
- 'order' => 'DESC',
- 'offset' => ($paged -1) * 10,
- 'tax_query' => array(
- 'relation' => 'AND',
- array(
- 'taxonomy' => 'location',
- 'field' => 'name',
- 'terms' => $location,
- ),
- array(
- 'taxonomy' => 'service',
- 'field' => 'name',
- 'terms' => $service,
- )
- ),
- );
- }
- ?>
- <div class="row" id="content">
- <div class="medium-3 columns" id="search-sidebar">
- <?php get_sidebar(); ?>
- </div>
- <div class="medium-9 columns" id="search-content">
- <h1><?php the_title(); ?></h1>
- <?php $listing_query = new WP_Query( $listing_args ); ?>
- <?php if($listing_query->have_posts() ): ?>
- <?php while( $listing_query->have_posts() ): $listing_query->the_post(); ?>
- <?php if( get_field('business_paid') ): ?>
- <div class="paying-listing columns">
- <div class="premium-business">
- <div class="large-6 columns">
- <?php the_post_thumbnail(); ?>
- </div>
- <div class="premium-single-listing row">
- <div class="large-6 columns premium-listing-content">
- <h3><?php the_title(); ?></h3>
- <?php if( get_field('phone_number') ): ?>
- <p><i class="fa fa-phone"></i> <?php the_field('phone_number'); ?></p>
- <?php endif; ?>
- <?php if( get_field('mobile') ): ?>
- <p><i class="fa fa-mobile"></i> <?php the_field('mobile_number'); ?></p>
- <?php endif; ?>
- <?php if( get_field('email') ): ?>
- <p><i class="fa fa-envelope-o"></i> <?php the_field('email'); ?></p>
- <?php endif; ?>
- <?php if( get_field('website') ): ?>
- <p><i class="fa fa-desktop"></i> <?php the_field('website'); ?></p>
- <?php endif; ?>
- <?php if( get_field('address') ): ?>
- <p><i class="fa fa-home"></i> <?php the_field('address'); ?></p>
- <?php endif; ?>
- <a href="<?php the_permalink(); ?>">Read More</a>
- </div>
- </div>
- </div>
- </div>
- <?php else: ?>
- <div class="non-paying-listing">
- <h3><?php the_title(); ?></h3>
- <?php if( get_field('phone_number') ): ?>
- <p><i class="fa fa-phone"></i> <?php the_field('phone_number'); ?></p>
- <?php endif; ?>
- <?php if( get_field('mobile') ): ?>
- <p><i class="fa fa-mobile"></i> <?php the_field('mobile_number'); ?></p>
- <?php endif; ?>
- <?php if( get_field('email') ): ?>
- <p><i class="fa fa-envelope-o"></i> <?php the_field('email'); ?></p>
- <?php endif; ?>
- <?php if( get_field('website') ): ?>
- <p><i class="fa fa-desktop"></i> <?php the_field('website'); ?></p>
- <?php endif; ?>
- <?php if( get_field('address') ): ?>
- <p><i class="fa fa-home"></i> <?php the_field('address'); ?></p>
- <?php endif; ?>
- </div>
- <?php endif; ?>
- <?php endwhile; ?>
- <?php wp_reset_postdata(); ?>
- <a href="<?php echo get_pagenum_link(2); ?>">Page 2</a>
- <?php else: ?>
- <p>No businesses found, please try again</p>
- <?php endif; ?>
- <?php wp_reset_query(); ?>
- </div>
- </div>
- <?php
- get_footer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement