Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $categories = get_categories();
- $do_not_duplicate = array();
- $last_cat = array();
- foreach ( $categories as $category ) {
- if($category->term_id!==4){
- $last_cat = array(
- 'cat' => $category->term_id,
- 'post_type' => 'post',
- 'posts_per_page' => '1',
- // 'category__not_in' =>4,
- 'post__not_in' => $do_not_duplicate
- );
- }//exclude
- $query_cat = new WP_Query($last_cat);
- if ( $query_cat->have_posts() ) {
- while ( $query_cat->have_posts() ) {
- $query_cat->the_post();
- $do_not_duplicate[] = $post->ID;
- $post_cat_thumbnail[] = get_the_post_thumbnail_url();
- $post_cat_title[] = get_the_title();
- $post_cat_excerpt[] = get_the_excerpt();
- $post_cat_url[] = get_the_permalink();
- }//while
- }//if
- wp_reset_postdata();
- }//foreach
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement