Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Template Name: Category TEST NEW
- *
- * @package WordPress
- * @subpackage Twenty_Eleven
- * @since Twenty Eleven 1.0
- */
- get_header(); ?>
- <section id="primary">
- <div id="content" role="main">
- <?php
- $all_cats = array( 4,5,6,7,8,16 ); //manual category list
- foreach( $all_cats as $cat ) {
- $latest_post = new WP_Query( array( 'posts_per_page' => 1, 'category__in' => array( $cat ) ) );
- $category = get_category($cat); //get category title
- if( $latest_post->have_posts() && $category ) : ?>
- <h2 class="category-title"><?php echo $category->name; ?></h3>
- <?php while( $latest_post->have_posts() ) : $latest_post->the_post(); ?>
- <?php get_template_part( 'content', get_post_format() ); ?>
- <?php endwhile;
- else : echo '<p>no post</p>';
- endif; wp_reset_postdata();
- }
- ?>
- </div><!-- #content -->
- </section><!-- #primary -->
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement