Php 自定义帖子类型查询未显示WordPress分页链接

Php 自定义帖子类型查询未显示WordPress分页链接,php,wordpress,pagination,Php,Wordpress,Pagination,我正在尝试为自定义帖子类型列表分页。这个列表显示的很好,但我似乎无法制作分页链接来显示 代码如下: <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'families', 'posts_per_page' => 9, 'pa

我正在尝试为自定义帖子类型列表分页。这个列表显示的很好,但我似乎无法制作分页链接来显示

代码如下:

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

        $args = array(
            'post_type' => 'families',
            'posts_per_page' => 9,
            'paged'=>$paged
        );

        $the_query = new WP_Query( $args );

    ?>

    <table class="families">

        <tr>
            <th class="family_head">Family Head</th>
            <th class="address">Address</th>
            <th class="contact_number">Contact number</th>
        </tr>

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

        <tr>

            <td><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></td>

            <td><?php the_field( 'residence_address' ); ?></td>

            <td class="contact_number"><?php the_field( 'mobile_number_1' ); ?></td>

        </tr>

        <?php endwhile; ?>

        <div class="navigation">
            <div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
            <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
        </div>

        <?php else: ?>

        <?php endif; ?>

    </table>

户主
地址
联系电话

用于分页的其他类似WP函数也不起作用。我做错了什么?

我认为这是获取查询变量(“paged”)的问题。在使用此代码的地方,已选中$paged, 试着替换这个

$paged=(获取查询变量('page'))?获取查询变量(“页面”):1

翻页与翻页之间存在差异。 你可以读更多


希望这会有所帮助。您可以问我是否可以进一步帮助您。谢谢我想这就是获取查询变量(“paged”)的问题所在,在您使用此代码的地方,已选中$paged, 试着替换这个

$paged=(获取查询变量('page'))?获取查询变量(“页面”):1

翻页与翻页之间存在差异。 你可以读更多


希望这会有所帮助。您可以问我是否可以为您提供进一步的帮助。谢谢。我删除了所有分页代码,然后重新执行。现在可以了。看看你能不能找到零钱

这是工作代码-

<div id="main_content">

<div id="main_content_otherpages">

    <?php

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

        $args = array(
            'post_type' => 'families',
            'posts_per_page' => 20,
            'paged' => $paged
        );

        $the_query = new WP_Query( $args );

    ?>

    <table class="families">

        <tr>
            <th class="family_head">Family Head</th>
            <th class="address">Address</th>
            <th class="contact_number">Contact number</th>
        </tr>

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

        <tr>

            <td><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></td>  

            <td><?php the_field( 'residence_address' ); ?></td>

            <td class="contact_number"><?php the_field( 'mobile_number_1' ); ?></td>

        </tr>

        <?php endwhile; ?>

    </table>

    <div style="clear:none; float:left"><?php next_posts_link( '&larr;Previous', $the_query->max_num_pages ); ?></div>
    <div style="clear:none; float:right"><?php previous_posts_link( 'Next&rarr;' ); ?></div>

    <?php wp_reset_postdata(); ?>

    <?php else: ?>

    <?php endif; ?>

</div>

户主
地址
联系电话

我删除了所有分页代码,然后重新执行。现在可以了。看看你能不能找到零钱

这是工作代码-

<div id="main_content">

<div id="main_content_otherpages">

    <?php

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

        $args = array(
            'post_type' => 'families',
            'posts_per_page' => 20,
            'paged' => $paged
        );

        $the_query = new WP_Query( $args );

    ?>

    <table class="families">

        <tr>
            <th class="family_head">Family Head</th>
            <th class="address">Address</th>
            <th class="contact_number">Contact number</th>
        </tr>

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

        <tr>

            <td><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></td>  

            <td><?php the_field( 'residence_address' ); ?></td>

            <td class="contact_number"><?php the_field( 'mobile_number_1' ); ?></td>

        </tr>

        <?php endwhile; ?>

    </table>

    <div style="clear:none; float:left"><?php next_posts_link( '&larr;Previous', $the_query->max_num_pages ); ?></div>
    <div style="clear:none; float:right"><?php previous_posts_link( 'Next&rarr;' ); ?></div>

    <?php wp_reset_postdata(); ?>

    <?php else: ?>

    <?php endif; ?>

</div>

户主
地址
联系电话

我试图显示此内容的页面不是静态首页。即使在那时,我还是尝试了你的建议。但它不起作用(你在$paged中得到了什么?)我试图在上面显示的页面不是一个静态的头版。即使在那时,我也尝试了你建议的内容。但它不起作用。:(你在$paged中得到了什么?)我不确定,但我认为这一行成功了。我不确定,但我认为这一行成功了。