Created
May 23, 2013 09:47
-
-
Save rajvanshipradeep15/5634999 to your computer and use it in GitHub Desktop.
wordpress: to query featured posts
This file contains hidden or 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
<!-- featured posts --> | |
<div class="span12"> | |
<?php | |
query_posts('category=featured&showposts=2'); | |
if (have_posts()) : | |
while (have_posts()) : the_post(); | |
?> | |
<div class="span5"> | |
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> | |
<?php | |
if(has_post_thumbnail()) { ?> | |
<div class="myfeaturedbox"> | |
<img src="<?php bloginfo('template_directory'); ?>/wp-content/themes/mytheme1/timthumb.php?src=<?php echo get_image_url(); ?>&h=290&w=430&zc=1" alt="<?php the_title(); ?>"/> | |
</div> | |
<?php | |
} | |
else { | |
echo '<div class="myfeaturedbox">'; | |
echo '<img src="'.get_bloginfo("template_url").'/assets/img/nothumb.jpg" alt="No Thumbnail"/>'; | |
echo "</div>"; | |
} | |
?> | |
<div class="" id="content_<?php echo $post->ID ?>" style="margin-top:20px;"> | |
<?php echo truncateWords($post->post_content,40)."..."; ?> | |
</div> | |
</div> | |
<?php | |
endwhile; | |
endif; | |
wp_reset_query(); | |
?> | |
</div> | |
<div class="featured_posts"></div> | |
<!-- featured posts end --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment