tags:

views:

1297

answers:

3

I have added a custom loop in my Wordpress template. WHich looks something like:

    <?php 
       $args = array('category__not_in' => array($featured_cat->term_id), 'posts_per_page' => 10, 'post__not_in' => array($recent_post) ); query_posts($args); ?>

For pagination to work, i guess i need to pass another arg 'paged'. And the value should be equal to the current page. What is the way to get the current page number in Wordpress?

+1  A: 

Not near a wordpress system to test this out at the mo, but you should be able to use:

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

(obviously defaulting to 1, if it has not been sent through).

Simon Scarfe
A: 

Use get_query_var('paged') like this

<?php 
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
$args = array('category__not_in' => array($featured_cat->term_id), 'posts_per_page' => 10, 'post__not_in' => array($recent_post), 'paged' => $paged );
query_posts($args); 
?>
aaronwaggs
A: 

Hey,

It should work when listing a category but when you need a list of thumbs based on post parent it doesn't seem to work.

Anybody knows how to fix it? On the wordpress forum I got some great help but it still does not work.

This is the code:

            <?php
         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        $args = array(
            'post_type' => page,
            'post_parent'  => $post->post_parent,
            'posts_per_page' => 12,
            'orderby' => menu_order,
            'paged'=>$paged,
            'order' => ASC
       );
        query_posts($args);

if ( has_post_thumbnail() ) {

} else {

}
while (have_posts()) : the_post(); ?>

     <li <?php if (is_page($post->ID)) { echo'class="current_page_item"'; } ?> id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a></li>
    <?php endwhile; ?>

Wordpress help: http://wordpress.org/support/topic/402635?replies=7

Juri