开发者

Getting pagenavi to work with a custom loop

<?php
/*
Template Name: Projects
*/
?>

<?php get_header();?>

    <section id="content">
        <section id="main">

            <?php
                $loop = new WP_Query(array('post_type' => 'projects', 'posts_per_page' => 4));
                $i=1;
                while ( $loop->have_posts() ) : $loop->the_post();
            ?>

            <article class="post<?php if($i%2 == 0) { echo ' right'; }; $i++; ?>" id="post-<?php the_ID(); ?>">
                <h2><?php the_title(); ?></h2>
                <section class="entry">
                    <?php the_excerpt(); ?>
                </section>
            </article>

            <?php
                endwhile;
                wp_pagenavi();
            ?>

            <section id="map">
                <img src="<?php bloginfo('template_url') ?>/images/interactive-map.jpg" alt="Interactive Map" />
            </section>
        </section>

<?php get_sidebar(); ?&开发者_Go百科gt;

    </section>

<?php get_footer(); ?>

I have pagenavi set up right after the endwhile. It's not working, though. It doesn't even show up in the source. Does anybody know how I can get this to work?


I was having this same problem. If you take out the posts_per_page parameter, the pagenavi will work. You will have to control the posts per page via Settings > Reading instead. I have not found any other work-arounds.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜