1
我做了分頁,但它不工作corrent,在每個頁面顯示相同的職位。wordpress在每個頁面分頁顯示相同的職位
代碼:
<?php if (have_posts()) : ?>
<?php $query = new WP_Query(array('post_type' => 'post', 'kalba' => 'Lietuviu', 'posts_per_page' => 2));?>
<?php while ($query->have_posts()) : $query->the_post();?>
<h2 class="title"><a href ="<?php the_permalink();?>"><?php echo $query->post->post_title;?></a></h2>
<div class="date"><?php echo mysql2date('Y-m-d', $query->post->post_date);?></div>
<div class="post"><p><?php echo $query->post->post_content;?></p></div>
<?php endwhile;?>
<? $big = 999999999; // need an unlikely integer
echo paginate_links(array('base' => str_replace($big, '%#%', get_pagenum_link($big)),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $query->max_num_pages,
'end_size'=> 1,
'mid_size'=> 10));?>
<?php endif; ?>
我不能發現問題,也許問題在於我使用 「分類學」。
它沒有解決問題 – Wizard
我忘了提及你要早調用if(have_posts())'。在調用該函數之前,您需要確定WP_QUERY是否帶有響應。移動你的查詢語句if if block –
不能工作,我嘗試打印$頁面,並在每個頁面中獲得「1」 – Wizard