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

Current Code

By: a guest on Jan 10th, 2013  |  syntax: PHP  |  size: 0.88 KB  |  views: 43  |  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.         foreach ($cats as $cat) {
  5.         query_posts("posts_per_page=1&orderby=rand&cat=".$cat->term_id);
  6.     ?>
  7.         <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  8.             <ul>
  9.                 <?php if (has_post_thumbnail()) { ?>
  10.                     <?php
  11.                         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>',
  12.                         apply_filters('get_term', $cat->name));
  13.                     ?>
  14.                 <?php } ?>
  15.             </ul>
  16.         <?php endwhile; else: ?>
  17.             <p><?php _e("Sorry, no posts matched your criteria."); ?></p>
  18.         <?php endif; } ?>
  19.     <?php wp_reset_query(); ?>