Can't get random 4 terms with images
-
This is driving me crazy.
With this code I can get all my terms in tax “categoria-proyecto” with the correct image<?php $taxonomy = 'categoria-proyecto'; $terms = apply_filters( 'taxonomy-images-get-terms', '', array('taxonomy' => $taxonomy) ); foreach( (array) $terms as $term) { echo '<div class="col-1-4"><div class="content">'; echo '<a href="'.esc_attr(get_term_link($term, $taxonomy)).'" class="redondeado">'; echo wp_get_attachment_image( $term->image_id, 'destacado-proyectos-home' ); echo '<span>'.$term->name.'</span></a></div></div>'; } ?>
but with this variation to get first 4 I simply CANT get the image, empty space and no image tag or url …
<?php $taxonomies = 'categoria-proyecto'; $args = array( 'orderby' => rand, 'number' => '4' ); $terms = get_terms( $taxonomies, $args ); if ( !empty( $terms ) && !is_wp_error( $terms ) ){ foreach( (array) $terms as $term) { echo '<div class="col-1-4"><div class="content">'; echo '<a href="'.esc_attr(get_term_link($term, $taxonomy)).'" class="redondeado">'; echo wp_get_attachment_image( $term->image_id, 'destacado-proyectos-home' ); echo '<span>'.$term->name.'</span></a></div></div>'; } }; ?>
Can Anybody help me please????
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Can't get random 4 terms with images’ is closed to new replies.