自定义 post 类型分页不起作用

Custom post type pagination not working

我知道这个问题已经被问过一千次了,我已经尝试复制我在这里找到的几乎所有解决方案,或者复制到 Wordpress 论坛(我也在那里发布了一个问题),但似乎没有什么能解决我的问题.

我从头开始创建了一个主题,我从 _underscores 下载了一个空白主题模板并从那里创建了其他所有内容。

最终目标是创建无限滚动,但我什至无法进行分页。如果有人可以帮助我,将不胜感激。

这是我的代码:

<?php
/*
Template Name: zvideos
*/
/**
 * @package zseventyfour
 */

get_header(); ?>

<?php
        $temp = $zvideos;
        $zvideos = null;
        $zvideos = new WP_Query();
        $zvideos ->query( 'showposts=2&post_type=zvideo' . '&paged=' . $paged );
        if( $zvideos->have_posts() ) {
            while( $zvideos->have_posts() ) {
                $zvideos->the_post();
                    $zvideo_date = get_post_meta($post->ID, 'zvideo_date', true);
                    $zvideo_client = get_post_meta($post->ID, 'zvideo_client', true);
                    $zvideo_location = get_post_meta($post->ID, 'zvideo_location', true);
                    $zvideo_vimeo = get_post_meta($post->ID, 'zvideo_vimeo', true);
                    $zvideo_screenshot01 = get_post_meta($post->ID, 'zvideo_screenshot01');
                    $zvideo_job01 = get_post_meta($post->ID, 'zvideo_job01', true);
                    $zvideo_job02 = get_post_meta($post->ID, 'zvideo_job02', true);
                    $zvideo_job03 = get_post_meta($post->ID, 'zvideo_job03', true);
                    $zvideo_name01 = get_post_meta($post->ID, 'zvideo_name01', true);
                    $zvideo_name02 = get_post_meta($post->ID, 'zvideo_name02', true);
                    $zvideo_name03 = get_post_meta($post->ID, 'zvideo_name03', true);
                ?>
                <section id="content">
                    <div class="wrapper">
                        <article>
                            <div class="vimeo">
                                <h1><?php the_title(); ?></h1>
                                <ul class="details">
                                    <li><?php echo $zvideo_date?></li>
                                    <li><?php echo $zvideo_client?></li>
                                    <li><?php echo $zvideo_location?></li>                              
                                </ul>
                                <div class="vimeo-wrapper">
                                    <iframe src="//player.vimeo.com/video/<?php echo $zvideo_vimeo?>" width="100%" height="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
                                </div>
                            </div>
                            <div class="footage">
                                <ul class="images">
                                    <li><img src="<?php echo $zvideo_screenshot01[0]?>" alt="<?php the_title(); ?>_01"/></li>
                                    <li><img src="<?php echo $zvideo_screenshot01[1]?>" alt="<?php the_title(); ?>_02"/></li>
                                    <li><img src="<?php echo $zvideo_screenshot01[2]?>" alt="<?php the_title(); ?>_03"/></li>
                                    <li><img src="<?php echo $zvideo_screenshot01[3]?>" alt="<?php the_title(); ?>_04"/></li>
                                    <li><img src="<?php echo $zvideo_screenshot01[4]?>" alt="<?php the_title(); ?>_05"/></li>
                                    <li><img src="<?php echo $zvideo_screenshot01[5]?>" alt="<?php the_title(); ?>_06"/></li>
                                </ul>
                            </div>
                            <div class="clearfix"></div>
                            <div class="info">
                                <ul class="credits">
                                    <li><p class="title"><?php echo $zvideo_job01?></p><p class="name"><?php echo $zvideo_name01?></p></li>
                                    <li><p class="title"><?php echo $zvideo_job02?></p><p class="name"><?php echo $zvideo_name02?></p></li>
                                    <li><p class="title"><?php echo $zvideo_job03?></p><p class="name"><?php echo $zvideo_name03?></p></li>
                                    <li><p class="title"><?php echo $zvideo_job?></p><p class="name"><?php echo $zvideo_name?></p></li>
                                    <li><p class="title"><?php echo $zvideo_job?></p><p class="name"><?php echo $zvideo_name?></p></li>
                                    <li><p class="title"><?php echo $zvideo_job?></p><p class="name"><?php echo $zvideo_name?></p></li>
                                </ul>
                            </div>
                        </article>
                    </div><!-- END O WRAPPER -->
                </section>          

                <?php

            }
        }
        else {
            echo '<div style="width=100%;text-align:center;font-size:180%;">Ooops! Something went <strong>terribly</strong> wrong...</br> Or there are no videos to show. Who knows, this is obscure stuff.</div>';
        }
    ?>
                <section>
                    <div class="navigation">
                      <div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
                      <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
                    </div>
                </section>
<?php get_footer(); ?>

我不知道如何解决这个问题。

提前致谢。

试试这个:

<?php echo paginate_links(array('base' => str_replace(999999999,'%#%', esc_url(get_pagenum_link(999999999))), 'format'=>'?paged=%#%', 'current'=>max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages, 'type' => 'list')); ?>

将此代码放在要显示导航栏的位置。

编辑: 使用以下代码修复的问题 -

<?php
    if (get_query_var('paged')) {
        $paged = get_query_var('paged');
    } elseif (get_query_var('page')) {
        $paged = get_query_var('page'); // Display posts from current page on a static front page
    } else {
        $paged = 1;
    }
    $args = array(
        'paged' => $paged,
        'posts_per_page' => 1,
        'post_type' => 'zvideos'
    );
    query_posts($args); 
?>

<?php if (have_posts()) : ?>

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

        <h2><?php the_title(); ?></h2>

    <?php endwhile; ?>

    <nav>
        <?php previous_posts_link(); ?>
        <?php next_posts_link(); ?>
    </nav>

<?php endif; ?>

<?php wp_reset_query(); ?>