0
我有一個很大的問題,使用自定義模板(page-location.php)分頁。 我在該模板中創建了一個自定義循環來查詢子頁面。除了分頁沒有顯示外,一切看起來都很棒。我嘗試了插件和wordpress默認分頁功能。我在這裏做錯了什麼?你能否給我一點時間並解釋它爲什麼沒有出現?提前致謝!請看代碼!我嘗試了所有解決方案..這個網站是我最後的希望。 ***請注意post_type ='page',而不是POST。WordPress的分頁問題post_type('頁')
<?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(); ?>
我不能感謝你纔好。我怎麼錯過這個簡單的觀點。你的回答節省了我很多時間。 :) – satancorpse