我在我的网站上使用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错误是因为你的永久链接没有被刷新。 前往永久链接,只需保存。你会看到它的工作:) –