View difference between Paste ID: ZW7Sb3H9 and uHdxB8Qj
SHOW: | | - or go back to the newest paste.
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(); ?>