Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2.  
  3. $categories = get_categories();
  4. $do_not_duplicate = array();
  5. $last_cat = array();
  6.  
  7. foreach ( $categories as $category ) {
  8.  
  9. if($category->term_id!==4){
  10. $last_cat = array(
  11. 'cat' => $category->term_id,
  12. 'post_type' => 'post',
  13. 'posts_per_page' => '1',
  14. // 'category__not_in' =>4,
  15. 'post__not_in' => $do_not_duplicate
  16. );
  17. }//exclude
  18.  
  19. $query_cat = new WP_Query($last_cat);
  20.  
  21. if ( $query_cat->have_posts() ) {
  22.  
  23. while ( $query_cat->have_posts() ) {
  24.  
  25. $query_cat->the_post();
  26. $do_not_duplicate[] = $post->ID;
  27.  
  28. $post_cat_thumbnail[] = get_the_post_thumbnail_url();
  29. $post_cat_title[] = get_the_title();
  30. $post_cat_excerpt[] = get_the_excerpt();
  31. $post_cat_url[] = get_the_permalink();
  32.  
  33. }//while
  34.  
  35. }//if
  36.  
  37. wp_reset_postdata();
  38.  
  39. }//foreach
  40.  
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement