Created
September 14, 2011 20:45
-
-
Save anonymous/1217737 to your computer and use it in GitHub Desktop.
Featured Post WP Query
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
<div style="clear:both;"></div> | |
<div id="slider_wrap"> | |
<div class="popular-post"> | |
<?php // ADD YOUR POPULAR POSTS SCRIPT HERE, OR OTHERWISE WIDGETIZE THIS SECTION ?> | |
</div> | |
<div id="slider"> | |
<div class="slides"> | |
<h1 class="mainSectionHeader">Featured</h1> | |
<ul> | |
<?php | |
$featuredPosts = new WP_Query(); | |
$featuredPosts->query(array('showposts' =>5, 'cat' =>8,'post_type' => array('post','events'))); | |
for($i=1; $i<=$featuredPosts; $i++) { // second for() loop for post slides | |
while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); // loop for posts | |
?> | |
<li id="slide-<?php echo $i++; ?>" class="clearfix"> | |
<div class="thumb clearfix"> | |
<?php if (has_post_thumbnail( $post->ID )): ?> | |
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?> | |
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/thumbs.php?src=<?php echo $image[0]; ?>&w=150&h=150&zc=1" alt="<?php the_title(); ?>" /></a> | |
<?php endif; ?> | |
</div> | |
<div id="featuredPanelText"> | |
<div class="postsnip"> | |
<h2><a href="<?php the_permalink(); ?>"><?php echo substr($post->post_title,0,30); // short title ?>...</a></h2> | |
<?php the_excerpt(); ?> | |
</div> | |
</div> | |
</li> | |
<?php endwhile; | |
} // end for() loop number 2 | |
?> | |
</ul> | |
</div> | |
<ul id="featuredPanelNav" class="slides-nav"> | |
<?php | |
$featuredPosts = new WP_Query(); | |
$featuredPosts->query(array('showposts' =>5, 'cat' =>8,'post_type' => array('post','events'))); | |
for($i=1; $i<=$featuredPosts; $i++) { // start for() loop | |
while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); // loop for posts titles | |
?> | |
<li class="on"><a href="#slide-<?php echo $i++; ?>"></a></li> | |
<?php endwhile; | |
} // end for() loop | |
?> | |
</ul> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment