Create Your Own Loop With WP_Query

<?php $recentPosts = new WP_Query(); $recentPosts->query(’showposts=5’); ?>   <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?> <!– do some stuff here –> <?php endwhile; ?> With Pagination: <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query(’showposts=5′.’&paged=’.$paged); ?> <!– do some stuff here –> <?php $wp_query = null; $wp_query = $temp; ?>

Related posts

<?php //Gets category info global $wp_query; $cats = get_the_category(); $tempQuery = $wp_query; $currentId = $post->ID;   //related category posts $catlist = ""; forEach( $cats as $c ) { if( $catlist != "" ) { $catlist .= ","; } $catlist .= $c->cat_ID; } $newQuery = "posts_per_page=6&orderby=rand&cat=" . $catlist; query_posts( $newQuery ); $categoryPosts = ""; $count =… Continue reading Related posts

Random Post list

<ul> <?php $args = array( ‘numberposts’ => 5, ‘orderby’ => ‘rand’ ); $rand_posts = get_posts( $args ); foreach( $rand_posts as $post ) : ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>

List of Posts

Simple list: <ul> <?php global $post; $args = array( ‘numberposts’ => 5, ‘offset’=> 1, ‘category’ => 1 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> All post data: <?php $args = array( ‘numberposts’ => 3 ); $lastposts = get_posts(… Continue reading List of Posts