Advertisement
Guest User

functions.php

a guest
Aug 21st, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. function homeServicios($attr)
  2. {
  3.  
  4.     $args_servicios  = array(
  5.                         'post_type' => 'servicios',
  6.                         'post_status' => 'publish',
  7.                         'ignore_sticky_posts' => true,
  8.                         'posts_per_page' => -1,
  9.                         'order' => 'ASC'
  10.                      );
  11.     // declaro la variable $query_banner para instanciar la clase WP_QUERY
  12.     // que tendra almacenada como parametro $args_servicios.
  13.     $query_servicios = new WP_QUERY( $args_servicios );
  14.  
  15.  
  16.     echo '<section>';
  17.  
  18.         echo '<div id="owl-demo" class="owl-carousel owl-theme">';
  19.  
  20.             // si tiene post
  21.             if( $query_servicios->have_posts() ):
  22.  
  23.                 // inicio el bucle while para mostrar la lista de servicios
  24.                 while( $query_servicios->have_posts() ): $query_servicios->the_post();
  25.  
  26.                     $titulo_servicio  = get_field('titulo');
  27.  
  28.                     echo '<div class="item">';
  29.                         echo '<figure class="caouselimg">';
  30.                             echo '<a href="'.get_permalink().'">';
  31.                                 echo '<img src="'.get_field('imagen_servicio').'" alt="'.$titulo_servicio.'">';
  32.                             echo '</a>';
  33.                         echo '</figure>';
  34.  
  35.                         echo '<aside class="carouseldescrip">';
  36.                             echo '<h3><a href="'.get_permalink().'">'.$titulo_servicio.'</a></h3>';
  37.                         echo '</aside>';
  38.  
  39.                     echo '</div>';
  40.  
  41.                 endwhile;
  42.  
  43.             endif;
  44.             wp_reset_postdata();
  45.  
  46.         echo '</div>';
  47.  
  48.         echo '<div class="customNavigation">';
  49.             echo '<a class="btn prev">Previous</a>';
  50.             echo '<a class="btn next">Next</a>';
  51.         echo '</div>';
  52.  
  53.     echo '</section>';
  54.  
  55. }
  56. add_shortcode('home-servicios','homeServicios');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement