post_type('page')的WordPress分页问题


Wordpress pagination issue with post_type('page')

我在使用自定义模板(页面位置.php)进行分页时遇到了很大的问题。我在该模板中创建了一个自定义循环来查询子页面。到目前为止,一切看起来都很棒,除了分页没有显示。我尝试了插件和wordpress默认分页功能。我在这里做错了什么?你能给我一点时间解释为什么它没有出现吗?提前感谢!请查看代码!我尝试了所有解决方案。这个网站是我最后的希望。请注意,post_type = "页面",而不是 POST。

<?php 
/*
    Template Name: Location Template
*/
?>
<?php get_header(); ?>
    <?php $options = get_option('katerina_custom_settings'); ?>
    <div class="container main-content">
        <h1><?php wp_title(''); ?></h1>
        <div class="row">
        <?php $this_page_id=$wp_query->post->ID; ?>
        <?php 
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            $my_query = new WP_Query("post_type=page&post_parent=$this_page_id&posts_per_page=2&paged=$paged");         
                if ($my_query->have_posts() ) : while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <div id="post-<?php the_ID(); ?>" <?php post_class('article span4 clearfix'); ?>>
                <?php if (has_post_thumbnail()) : ?>
                    <figure class="article-preview-image">
                        <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
                    </figure>
                <?php endif; ?>
                <article class="content clearfix">
                    <?php if (get_the_title() != '') : ?>
                        <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                    <?php else : ?>
                        <a href="<?php the_permalink(); ?>"><?php _e('Permalink to the post', 'adaptive-framework'); ?></a>
                    <?php endif; ?>
                    <?php the_content(); ?>
                    <a href="<?php the_permalink(); ?>" class="button">Details</a>
                </article>
                <div class="meta-data clearfix">
                    <ul class="meta-comments pull-left">
                        <li class="article-meta-comments">
                            <?php
                            // Only show the comments link if comments are allowed and it's not password protected
                                if (comments_open() && !post_password_required()) { 
                                    comments_popup_link('0', '1', '%', 'article-meta-comments');
                                }
                            ?>
                        </li>
                        <li class="article-meta-like"><a href="">10</a></li>
                    </ul>
                    <ul class="social-share pull-right">
                        <li class="fb"><a href="#">Share on Facebooks</a></li>
                        <li class="google"><a href="#">Share via Google</a></li>
                        <li class="twitter"><a href="#">Share via Twitter</a></li>
                    </ul>
                </div>  
            </div>
            <?php endwhile; ?>
        <?php endif; ?>
            <?php wp_reset_postdata(); ?>           
        </div>
        <!-- end row -->
    </div>
        <div class="container">
        <div class="pagination pull-right">
            <?php if(function_exists('tw_pagination')) 
                tw_pagination();
            ?>  
        </div>
    </div>
    <!-- end main-content -->

<?php get_footer(); ?>

你应该试试这个

<div class="pagination pull-right">
        <?php if(function_exists('tw_pagination')) 
            tw_pagination($my_query);
        ?>  
    </div>