As we all know wordpress is the light weight web CMS.It is easy to customize to meet your customers need.
The wordpress loop(wp loop) play the role to fetch the required posts from db and show it.If you previously worked with the WP.you may be familiar with it.If not,you can figure it out just going to wordpress themes folder(wp-content/themes) and open the index.php file.The codes are :
<?php if (have_posts('')) : while (have_posts()) : the_post(); ?>
Here have_posts(),the_posts() are both the functions that access the property method of Wp_query() class.Wp_query() locates at “wp-incldes/query.php”
In some of the themes “query_posts()” is used but for customization tasks,its better to create an instantiate the own “Wp_Query()” for custom loop.
Lets start to customize a loop.Just remove the previous loop, and create a new instantiate of “Wp_Query()”.And declare the category of the posts you want to display through the loop.
<?php $my_query = new WP_Query('p=85,111'); //retrieving only post no 85 and 111 have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?>
You can customize the loop using different kinds of parameters in based of posts,category etc.
For having more query specific result you can pass specific arugements as form of array.Code example will be like below:
<?php $args = array('post_type'=>'post','post__in'=>array('1','4','6')); $my_query = new WP_Query($args); if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?>
You can use these kinds of customized loop for having different posts and pages.
For details about Wp_Query,Click Here
For customizing any plugin related to post display(Ex. gallery plugins)you can use custom loop.Also in differenet conditional posts can be displayed using custom loop.
For having further details about loop,Click Here