Last active
October 30, 2017 17:25
-
-
Save zazk/dc0943daeb074f2a4e62f6a781f75d85 to your computer and use it in GitHub Desktop.
Taxonomy Recursive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $namelinea = $_POST['termname']; | |
| $args = array( | |
| 'post_type' => 'productos', | |
| 'posts_per_page' => 3, | |
| 'taxonomy' => 'linea-maquinaria', | |
| 'term' => $namelinea, //slug de terminos | |
| 'nopaging' => true, // to show all posts in this taxonomy, could also use 'numberposts' => -1 instead | |
| ); | |
| $args = new WP_Query($args); | |
| while($args->have_posts()): $args->the_post(); | |
| $images = []; | |
| if( have_rows('galeria_de_imagenes') ): | |
| while( have_rows('galeria_de_imagenes') ): the_row(); | |
| $images[] = get_sub_field('imagen_producto'); | |
| endwhile; | |
| endif; | |
| $post_data[] = array( | |
| 'titulo' => get_the_title(), | |
| 'imagen' => $images | |
| ); | |
| $images = null; | |
| endwhile; wp_reset_postdata(); | |
| echo json_encode( $post_data ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment