In this article am going to explain how to display category posts in home page.
<?php $recent = new WP_Query(); ?>
<?php $recent->query('cat=1&showposts=3'); //set your category id and limit for posts ?>
<?php while($recent->have_posts()) : $recent->the_post(); ?>
<?php
if ( is_single() ) :
the_title( '<h1 class="entry-title">', '</h1>' );// post title
else :
the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' );
endif; ?>
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?>
<?php the_excerpt(); ?>
<div class="readmore"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read More</a></div>
<?php $recent = new WP_Query(); ?>
<?php $recent->query('cat=1&showposts=3'); //set your category id and limit for posts ?>
<?php while($recent->have_posts()) : $recent->the_post(); ?>
<?php
if ( is_single() ) :
the_title( '<h1 class="entry-title">', '</h1>' );// post title
else :
the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' );
endif; ?>
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?>
<?php the_excerpt(); ?>
<div class="readmore"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read More</a></div>
No comments:
Post a Comment