0

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 -->
0

1 Answer 1

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" );
1
  • 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
    Commented Oct 17, 2013 at 11:54

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