Advertisement
thiago_db

tax query

Dec 22nd, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.18 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: Resultados
  4. */
  5. ?>
  6.  
  7. <?php get_header(); ?>
  8.  
  9. <div class="container">
  10.  
  11.     <?php include 'sidebar-left.php'; ?>   
  12.  
  13.     <section class="conteudo">
  14.         <div class="box-resultados">Exebindo 1-10 de 10 resultados</div>
  15.  
  16.         <?php
  17.  
  18.         $args = array(
  19.             'post_type' => 'post',
  20.             'tax_query' => array(
  21.                 'relation' => 'AND',
  22.                 array(
  23.                     'taxonomy' => 'estado',
  24.                     'field'    => 'slug',
  25.                     'terms'    => $estado,
  26.                     'operator' => 'AND',
  27.                 ),
  28.                 array(
  29.                     'taxonomy' => 'regiao',
  30.                     'field'    => 'slug',
  31.                     'terms'    => $regiao,
  32.                     'operator' => 'AND',
  33.                 ),
  34.                 array(
  35.                   'taxonomy' => 'bairro',
  36.                   'field' => 'slug',
  37.                   'terms' => $bairro,  
  38.                   'operator' => 'AND',     
  39.                 ),
  40.                 array(
  41.                   'taxonomy' => 'especialidade',
  42.                   'field' => 'slug',
  43.                   'terms' => $especialidade,  
  44.                   'operator' => 'AND',     
  45.                 ),
  46.                 array(
  47.                   'taxonomy' => 'ambiente',
  48.                   'field' => 'slug',
  49.                   'terms' => $ambiente,  
  50.                   'operator' => 'AND',     
  51.                 ),
  52.                 array(
  53.                   'taxonomy' => 'delivery',
  54.                   'field' => 'slug',
  55.                   'terms' => $delivery,  
  56.                   'operator' => 'AND',     
  57.                 ),
  58.             ),
  59.         );
  60.         $query = new WP_Query( $args );
  61.    
  62.          if($query->have_posts()):
  63.  
  64.          while($query->have_posts()):
  65.  
  66.          $query->the_post(); ?>
  67.      
  68.         <article>
  69.             <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( array(184, 184) ); ?></a>
  70.             <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
  71.             <ul>
  72.                 <li><img src="<?php bloginfo('stylesheet_directory'); ?>/imagem/icon-map.png" width="22" height="18"><?php the_field( "bairro" ); ?></li>
  73.                 <li><img src="<?php bloginfo('stylesheet_directory'); ?>/imagem/icon-tel.jpg"> <?php the_field( "telefone" ); ?></li>
  74.                 <li><img src="<?php bloginfo('stylesheet_directory'); ?>/imagem/icon-seta.png"> <a href="<?php the_permalink(); ?>">Saiba mais</a></li>
  75.             </ul>
  76.         </article>
  77.        
  78.         <?php
  79.         endwhile;  
  80.         endif;
  81.         ?>     
  82.        
  83.         </section>
  84.  
  85.         <?php include 'sidebar-right.php'; ?>
  86.  
  87. </div>
  88.  
  89. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement