Advertisement
all2aller

Get Post Thumbnail URL in WP_Query Loop by Category

Aug 13th, 2015
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2.    $gallery_loop = new WP_Query(array(
  3.    
  4.       'post_status' => 'publish',
  5.    
  6.       'order'       => 'ASC',
  7.    
  8.       'posts_per_page' => -1,  // Qui scegli il numero di post da mostrano -1 = tutti
  9.    
  10.       'cat'   => 2,  // Qui l'id della categoria interessata
  11.    
  12.    
  13.    ));
  14.    
  15.    while($gallery_loop->have_posts()): $gallery_loop->the_post(); ?>
  16. <?php  
  17.    $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
  18.    
  19.    echo $url; // Qui stampi l'url della thumbnail del post
  20.    
  21.    ?>
  22. <?php endwhile; ?>
  23. <?php wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement