Created
February 13, 2014 21:58
-
-
Save anonymous/8984741 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setup loop to pull only posts tagged slider | |
$max = 6; | |
$args = array('tag' => 'slider','posts_per_page' => $max); | |
$featuredPosts = new WP_Query(); | |
$featuredPosts->query($args); | |
// Defaults for post thumbnail display | |
$thumbargs = array('class' => 'featured-blocks-img'); | |
$thumbsize = array(640,360); | |
$count = 0; | |
// Begin loop | |
if ($featuredPosts->have_posts()) : while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); | |
$count++; | |
// Get post category and format for div class name | |
$category = get_the_category(); | |
$catname = $category[0]->cat_name; | |
$catdash = 'cat-'; | |
$catdash .= str_replace(' ', '-', $category[0]->cat_name); | |
$catdash = strtolower($catdash); | |
// Change post thumbnail size conditionally | |
switch ($count) { | |
case 2: | |
case 5: | |
case 6: | |
$thumbsize == array(320,260); | |
break; | |
default: | |
$thumbsize == array(640,360); | |
} // End switch | |
?> | |
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> | |
<div id="home-featured-post-<?php echo $count;?>" class="featured-blocks-post <?php echo $catdash; ?>"> | |
<h2 class="home-featured-title"><?php the_title(); ?></h1> | |
<?php the_post_thumbnail($thumbsize, $thumbargs); ?> | |
</div> | |
</a> | |
<?php | |
endwhile; | |
endif; // End loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment