0

This question already has an answer here:

When I set this template as homepage, pagination doesn't work. I see the buttons, but when I click the button for page 2, nothing happens, doesn't go on page 2, it still remain in page 1.

What is wrong? Where is the mistake?
I read all posts from here & from internet about this issue, but nothing works.

Solution for pagination is this: kriesi.

Here is the code:

<!-- MAIN CONTENT -->
<section id="main-container">
    <div class="row">
        <div class="content">

            <?php if (have_posts()) : while (have_posts()) : the_post();?>

            <?php   
            $template_name =   get_post_meta( $wp_query->post->ID, '_wp_page_template', true );
            $post_type =  str_replace( array('template-', '.php'), array(''), $template_name);
            ?>

            <?php the_content(); ?>

            <?php endwhile; endif; ?>
            <?php 
            $loop = new WP_Query("post_type=$post_type&paged=$paged");
            if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post(); ?>

             <?php get_template_part('loop', $post_type) ?>


                                       <?php endwhile; ?> 
                                       <?php else: ?>
                <?php require THEME_DIR.'/empty.php'; ?>
                                       <?php endif; ?>


                                       <?php pagination($loop->max_num_pages); ?>
        </div>

        <?php get_sidebar(); ?>
    </div>
</section>
<!-- END MAIN CONTENT -->

marked as duplicate by Chip Bennett, fuxia Oct 17 '13 at 11:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

You probably don't set the $paged variable correctly. Try to rewrite your code like this:

$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$loop = new WP_Query( "post_type=$post_type&paged=$paged" );
  • Doesn't work, but you give me an idea. In this way works. Before $loop i put this & it's OK: if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } – Blanka Oct 17 '13 at 11:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.