[英]How to fix wordpress pagination redirect?
我在 wordpress category.php
中使用分页。php 页面。 一切都很好,但是当我单击下一页时出现以下错误
Template is missing. Standalone themes need to have a index.php template file. Child themes need to have a Template header in the style.css stylesheet.
我的 url 有点像
https://test.com/category/cat_name/page/2/
这是我的代码:
$cat_name = $category->name;
$cat_id = get_cat_ID( $cat_name );
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts=1&post_type=post&paged='.$paged.'&cat='.$cat_id);
while ($wp_query->have_posts()) : $wp_query->the_post();
/// loop here
<?php endwhile; ?>
分页代码:
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo '<div class="custom-pagination">';
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'prev_text' => __('Previous'),
'next_text' => __('Next'),
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
echo '</div>';
?>
我应该在 htaccess 文件或 function.php 中添加一些代码以在 category.php 中重定向吗?
我自己得到了答案。 我需要更改仪表板阅读部分中Blog pages show at most
。 我在Blog pages show at most
showposts
,即最多 1 个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.