bishawjit-das
11/22/2015 - 6:56 AM

Wordpress default query_posts function modification

Wordpress default query_posts function modification

query_posts parameter

	attachment
	attachment_id
	author
	author_name
	cat
	category__and
	category__in
	category__not_in
	category_name
	comments_popup
	day
	error
	feed
	hour
	m
	minute
	monthnum
	name
	order
	orderby
	p
	page_id
	page
	paged
	pagename
	post__in
	post__not_in
	post_status
	post_type
	preview
	robots
	s
	sentence
	second
	static
	subpost
	subpost_id
	tag__and
	tag__in
	tag__not_in
	tag_id
	tag_slug__and
	tag_slug__in
	tag
	taxonomy - (pre 3.1)
	tb
	term - (pre 3.1)
	w
	withcomments
	withoutcomments
	year
	

	<?php query_posts( array ( 'posts_per_page' => 1 ) ); ?>
	<?php if ( have_posts() ) : ?>
	<?php while ( have_posts() ) : the_post(); ?>
	<?php $ids[] = get_the_ID(); ?> // Getting the id / ids of the first loop
		// Do whatever you want with first loop
	<?php endwhile; ?>
	<?php wp_reset_query(); ?>
	<?php endif; ?>
	
	<?php query_posts(array( 'post__not_in' => $ids, 'paged' => get_query_var('paged') )); ?>
	<?php if ( have_posts() ) : ?>
	<?php while ( have_posts() ) : the_post(); ?>
	<?php $ids[] = get_the_ID(); ?> // Getting the id / ids of the first loop
		// Do whatever you want with second loop
	<?php endwhile; ?>
	<?php wp_pagenavi(); ?>
	<?php endif; ?>

	
Ref: http://www.smashingmagazine.com/2009/06/10-useful-wordpress-loop-hacks