Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php // cycle through categories, print 1 post for each category
- $exclude = '1'; //exclude 'uncategorized'//
- $lastpost = get_posts('numberposts=1'); //get the last post
- $last_cats = get_the_category($lastpost[0]->ID); //get the categor(y/ies) from the last post and add to the exclude list//
- foreach($last_cats as $last_cat) {
- $exclude .= ','.$last_cat->term_id;
- }
- $categories=get_categories('orderby=name&order=ASC&exclude='.$exclude);
- foreach($categories as $category) {
- $posts=get_posts('showposts=1&cat='. $category->term_id);
- if ($posts) {
- echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
- foreach($posts as $post) {
- setup_postdata($post); ?>
- <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
- <?php
- } // foreach($posts
- } // if ($posts
- } // foreach($categories
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement