Advertisement
afsarwebdev

WP Specific Post Format display

May 24th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. //Specific Post format post display
  2. <?php
  3. // the query
  4. $slider_post = new WP_Query(array(
  5. 'post_type' => 'post',
  6. 'posts_per_page' => 3,
  7. 'tax_query' => array(
  8. array(
  9. 'taxonomy' => 'post_format',
  10. 'field' => 'slug',
  11. 'terms' => array( 'post-format-gallery' ),
  12. 'operator' => 'IN'
  13. )
  14. )
  15. ));
  16.  
  17. ?>
  18.  
  19. <?php if ($slider_post->have_posts()):
  20.  
  21. while ($slider_post->have_posts()) : $slider_post->the_post();
  22.  
  23. if( get_post_format() == 'gallery' ) : ?>
  24.  
  25. //My html dynamic code here
  26.  
  27. <?php endif;
  28.  
  29. endwhile;
  30. else :
  31. echo wpautop('Sorry, no posts were found');
  32. endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement