Simple Query post wordpress

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.

Show post with simple Query post wordpress


<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 -->

Arguments used for query post


<?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.

Leave a Reply

Your email address will not be published. Required fields are marked *