我試圖讓分頁兩種文章類型這是一個自定義後類型question
和正常post
首先,當我顯示所有結果without pagination
使用'posts_per_page' => -1;
結果的功能工作正常WordPress的wp_Query分頁定製post_type問題
,但問題發生時,我儘量讓分頁,你可以看到分頁功能正常工作,除了分頁(我猜其中包含的問題post_type甚至最近的支柱式結構問題出現的一些最後幾頁通常)
這裏你是我的全部代碼
<?php
$my_query = new WP_Query(
array(
'post_type' => array('question', 'post'),
'posts_per_page' => get_option('to_count_portfolio'), // -1 to show all results
'author' => $post->post_author,
'paged' => get_query_var('paged') ? get_query_var('paged') : 1
)
);
?>
<?php
while ($my_query->have_posts()) : $my_query->the_post();
?>
<span class="title">
<?php echo get_post_type(); ?>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</span>
<br />
<?php endwhile; ?>
<?php
$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' => $my_query->max_num_pages
)
);
?>
我怎樣才能讓分頁正常工作,並導航到所有分頁鏈接?
謝謝@Arpan我改變我的代碼與你的,但我仍然相同404 last for the page –