Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Updated code

By: a guest on Jan 11th, 2013  |  syntax: PHP  |  size: 0.88 KB  |  views: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.     $parent = get_cat_ID("photos");
  3.     $cats = get_categories("child_of=".$parent);
  4.  
  5.     echo '<pre>';
  6.         print_r( $cats );
  7.     echo '</pre>';
  8.  
  9.     foreach ($cats as $cat) {
  10.         query_posts( array (
  11.             'showposts' => 1,
  12.             'orderby' => 'rand',
  13.             'cat' => $cat->cat_ID
  14.     ) );
  15. ?>
  16. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  17.     <ul>
  18.         <?php if (has_post_thumbnail()) { ?>
  19.         <?php
  20.             printf( '<li><a href="'.get_category_link($cat->term_id).'">'.get_the_post_thumbnail(get_the_ID(), "album-thumb").'</a><a href="'.get_category_link($cat->term_id).'">%s</a></li>',
  21.             apply_filters('get_term', $cat->name));
  22. ?>
  23.         <?php } ?>
  24.     </ul>
  25. <?php endwhile; else: ?>
  26.     <p><?php _e("Sorry, no posts matched your criteria."); ?></p>
  27. <?php endif; } ?>
  28. <?php wp_reset_query(); ?>
clone this paste RAW Paste Data