This is 100% untested, 但你可能想试试这个/胡闹一下
<?php
$args = array(
\'orderby\' => \'name\',
\'order\' => \'ASC\',
);
$categories = get_categories( $args );
foreach( $categories as $category )
{
$loopcounter = 0;
$args = array(
\'post_type\' => \'post\',
\'post_status\' => \'publish\',
\'posts_per_page\' => 1,
\'caller_get_posts\'=> 1
);
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : $the_query->the_post(); $loopcounter++; ?>
<?php if ( in_array($loopcounter, array( 1,2,3,4 ) )) : ?>
<li class="span<?php echo $loopcounter; ?> box portfolio-entry loopcounter-<?php echo $loopcounter; ?>">
<div class="hover-state align-right">
<h2><?php the_category(); ?></h2>
<h3><?php the_title(); ?></h3>
<em>Click for details</em>
</div><!-- end hover-state -->
<?php if (has_post_thumbnail()) : ?>
<figure><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></figure>
<?php endif; ?>
</li>
<?php elseif ($loopcounter == 5 ) : ?>
<h3>Title whatever this is goes here</h3>
<?php elseif ( in_array($loopcounter, array( 6,7,8,9 ) )) : ?>
<li class="span<?php echo $loopcounter; ?> box portfolio-entry loopcounter-<?php echo $loopcounter; ?>">
<div class="hover-state align-right">
<h2><?php the_category(); ?></h2>
<h3><?php the_title(); ?></h3>
<em>Click for details</em>
</div><!-- end hover-state -->
<?php if (has_post_thumbnail()) : ?>
<figure><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></figure>
<?php endif; ?>
</li>
<?php else : ?>
<?php endif; ?>
<?php endwhile; } wp_reset_postdata(); ?>