Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $parent = get_cat_ID( 'photos' );
- $cats = get_categories("child_of=".$parent);
- foreach ($cats as $cat) {
- query_posts( array (
- 'posts_per_page' => 1,
- 'orderby' => 'rand',
- 'cat' => $cat->cat_ID
- ) );
- ?>
- <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
- <ul>
- <?php if (has_post_thumbnail()) { ?>
- <?php
- printf( '<li><a href="'.get_category_link($cat->cat_ID).'">'.get_the_post_thumbnail(get_the_ID(), "album-thumb").'</a><a href="'.get_category_link($cat->term_id).'">%s</a></li>',
- apply_filters('get_term', $cat->name));
- ?>
- <?php } ?>
- </ul>
- <?php endwhile; endif; } ?>
- <?php if (!$cat == true) { ?>
- <p><?php _e("Sorry, no posts matched your criteria."); ?></p>
- <?php } ?>
- <?php wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement