Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [WordPress] Multiple loops & pagination (Sticky posts not on absolute top) Re: [WordPress] Multiple loops & pagination (Sticky posts not on absolute top)

#106967
Spiekerboks
Participant

Ah wonderfull, thank you Zardos!

For future reference my working code:


$pageNumber = 	(get_query_var('paged')) ? get_query_var('paged') : 1;
$offseta = ($pageNumber * 10 - 10);
$offsetb = (1 + $pageNumber * 10 - 10);
?>

// Requests latest normal post, excluding the announcement category
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

//... content...//

endwhile; endif;// End the Loop and Check for Posts
wp_reset_query(); // Reset the loop
?>

// Requests latest post in announcement category
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

//... content...//

endwhile; endif;// End the Loop and Check for Posts
wp_reset_query(); // Reset the loop
?>

// Requests latest eight normal post, excluding the announcement category and without duplicating the first entry
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

//... content...//

endwhile; endif;// End the Loop and Check for Posts
wp_reset_query(); // Reset the loop
?>

Notice I had to use double quotes, otherwise PHP takes things to literally ;). Also the paged-var defaults to zero apparently so I had to alter that to 1 for my calculations to work (otherwise there would be a negative offset on the homepage).

One small problem remains: The pagination plugin (WP-Paginate) outputs two pages to many which only show the announcement. I can certainly live with that but if someone knows the reason and/or a solution I’d like to hear it (therefore I have not yet checked the solved box).

Thanks again Zardos!