Advertisement
Guest User

Updated code

a guest
Jan 11th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  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(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement