2013-11-14 18:19 阅读 67


I am having a great problem with pagination using a custom template(page-location.php). I created a custom loop in that template to query child pages. Everything looks great so far except the pagination's not showing up. I tried both with plugins and wordpress default pagination functions. What am I doing wrong here? Can you please give me a moment and explain why it's not showing up? Thanks in advance! Please have a look at the codes! I tried every solutions out there.. This site is my last hope. ***Please note that post_type = 'page', not POST.

    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; ?>

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

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

                <div class="meta-data clearfix">
                    <ul class="meta-comments pull-left">
                        <li class="article-meta-comments">
                            // 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 class="article-meta-like"><a href="">10</a></li>

                    <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>
            <?php endwhile; ?>
        <?php endif; ?>

            <?php wp_reset_postdata(); ?>           
        <!-- end row -->

        <div class="container">
        <div class="pagination pull-right">
            <?php if(function_exists('tw_pagination')) 
    <!-- end main-content -->

<?php get_footer(); ?>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    douliangli6407 douliangli6407 2013-11-14 20:22

    You should try this

    <div class="pagination pull-right">
            <?php if(function_exists('tw_pagination')) 
    点赞 评论 复制链接分享