Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Code

By: a guest on Jan 11th, 2013  |  syntax: PHP  |  size: 0.85 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3.     $parent = get_cat_ID( 'photos' );
  4.     $cats = get_categories("child_of=".$parent);
  5.  
  6.     foreach ($cats as $cat) {
  7.     query_posts( array (
  8.         'posts_per_page' => 1,
  9.         'orderby' => 'rand',
  10.         'cat' => $cat->cat_ID
  11.     ) );
  12. ?>
  13. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  14.     <ul>
  15.         <?php if (has_post_thumbnail()) { ?>
  16.         <?php
  17.             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>',
  18.             apply_filters('get_term', $cat->name));
  19.         ?>
  20.         <?php } ?>
  21.     </ul>
  22. <?php endwhile; endif; } ?>
  23.     <?php if (!$cat == true) { ?>
  24.         <p><?php _e("Sorry, no posts matched your criteria."); ?></p>
  25.     <?php } ?>
  26. <?php wp_reset_query(); ?>