Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="latest-posts">
- <?php
- $cat_args=array(
- 'include' => '1,2,3,4', // categories to display separated by commas
- 'orderby' => 'ID', // ordered by category id - options - ID, name, slug, count, term_group
- 'order' => 'ASC' // order ascending
- );
- $categories=get_categories($cat_args);
- foreach($categories as $category) {
- $args=array(
- 'showposts' => 4, // number of posts to display
- 'category__in' => array($category->term_id),
- 'ignore_sticky_posts'=>1 // number of sticky posts to ignore in the listing
- );
- $posts=get_posts($args);
- if ($posts) {
- echo '<ul class="preview"><div class="preview-header"><div class="category"><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a></div></div>';
- foreach($posts as $post) {
- setup_postdata($post); ?>
- <li>
- <div class="image"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'small' ); ?></a></div>
- <h4 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>
- </li>
- <?php
- }
- echo '</ul>'; }
- }
- ?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement