A simple query post wordpress to display post in any format you desire. Basically sometime you may need to call some limited number of post with specific category in certain place of your home page or any other template. This will require you to do some hand coding of wordpress inbuilt php function. WordPress has many easy to use php function that will fulfill your desire to show post.
<div class="boxKey">
<?php
$args = array(
'post_type'=> 'post',
'category_name' => 'home',
'order' => 'ASC'
);
query_posts( $args );
// The Loop
while ( have_posts() ) : the_post(); ?>
<div class="boxImg">
<a href="<?php the_permalink(); ?>"> <?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?></a>
<div class="boxTextKey">
<h1><?php the_title() ?></h1>
<p><?php the_excerpt(); ?> </p>
</div>
<a href="<?php the_permalink()?>" class="arrowKey"> </a>
<div class="clear"></div>
</div>
<?php
endwhile;
// Reset Query
?>
<?php wp_reset_query(); ?>
</div>
<!-- /.boxKey -->
<?php
$args = array(
'post_type'=> 'post',
'category_name' => 'home',
'order' => 'ASC',
'cat=-1,-2,-3', //excluding post on the base of category id
);
?>
For more detail information please visit here
The post Simple Query post wordpress appeared first on Santosh Shah.