Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $parent = get_cat_ID( 'photos' );
- if ( is_category( $parent ) ) {
- $cats = get_categories( 'child_of=' . $parent );
- foreach ( $cats as $cat ) {
- query_posts( array (
- 'showposts' => 1,
- 'orderby' => 'rand',
- 'cat' => $cat->term_id
- ) );
- if ( have_posts() ) :
- while ( have_posts() ) :
- the_post();
- $image = '';
- if ( has_post_thumbnail() )
- $image = get_the_post_thumbnail( get_the_ID() );
- echo '<ul>';
- printf( '<li>%s<a href="%s">%s</a></li>',
- $image,
- get_category_link( $cat->term_id ),
- apply_filters( 'get_term', $cat->name ) );
- echo '</ul>';
- endwhile;
- else:
- // CATEGORY HAS NO POSTS
- endif;
- }
- } else {
- // CATEGORY DOESN'T EXIST
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement