我在我的網站上使用WP初學者分頁(無插件),但我無法訪問第二頁和其他頁面。Wordpress分頁 - 無法訪問第二頁
<?php
$category = get_category(get_query_var('cat'));
$cat_id = $category->cat_ID;
$custom_query_args = array(
'post_type' => array('tutorials','post'),
'posts_per_page' => 2,
'cat' => $cat_id,
);
// Get current page and append to custom query parameters array
$custom_query_args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1;
// Instantiate custom query
$custom_query = new WP_Query($custom_query_args);
// Pagination fix
$temp_query = $wp_query;
$wp_query = NULL;
$wp_query = $custom_query;
// Output custom query loop
if ($custom_query->have_posts()) :
while ($custom_query->have_posts()) :
$custom_query->the_post();
echo '<article class="other-post col-xs-12 col-sm-12 col-md-3 col-lg-3">';
echo '<div class="back-color">';
echo '<h3>';
echo the_post_thumbnail('post-thumbnail', array('class' => 'post-image'));
echo '<a href="'. get_permalink() .'" title="'. get_the_title() .'">';
echo '<span><b>'. get_the_title() .'</b></span>';
echo '</a>';
echo '</h3>';
echo '</div>';
echo '</article>';
endwhile;
endif;
// Reset postdata
wp_reset_postdata();
// Custom query loop pagination
wpbeginner_numeric_posts_nav();
// Reset main query object
$wp_query = NULL;
$wp_query = $temp_query;
?>
這裏是function.php的代碼,但我認爲這不是問題。 http://virtual-wizard.eu/function.txt
我看到你正在使用wpbeginner的代碼..我測試了自定義主題上的代碼。我已經制作了一個教程。 (已測試) https://prabinparajuli.com.np/add-custom-pagination-in-wordpress/ –
您的解決方案也出現同樣的錯誤。 – CRooY3
您是否沖洗了您的永久鏈接?我認爲404錯誤是因爲你的永久鏈接沒有被刷新。 前往永久鏈接,只需保存。你會看到它的工作:) –