timple-c
11/29/2017 - 8:12 PM

Recorre las categorías y trae los posts

Recorre las categorías y trae los posts

<?php

// Define la taxonomy

$taxonomia = "puntosventa";

// Denir argumentos. http://codex.wordpress.org/Function_Reference/get_terms

$args = array( 'hide_empty=0' );

// Nombre de la taxonomía. Devuelve todo en un array

$terms = get_terms($taxonomia, $args);

// Si efectivamente devolvió algo

if ( !empty( $terms ) && !is_wp_error( $terms ) ) {

  foreach ($terms as $term) {

      $the_query = new WP_Query( array ( $taxonomia => $term->slug  ));
      while ( $the_query->have_posts() ) : $the_query->the_post();
      
        // AQUI VA EL CONTENIDO DE LOS POST

      endwhile;
      // Reset Post Data
      wp_reset_postdata();


  }

}

?>