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.
<?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(); ?>