我的博客帖子页面:mysite.com/blog
=> 工作日志页面分页:mysite.com/blog/page/2
=>工作类别帖子url:mysite.com/blog/cat
=> 工作帖子url:mysite.com/blog/cat/postname
=> 工作分类分页后url:mysite.com/blog/cat/page/2
=>404:-(
永久性结构:/blog/%category%/%postname%/
使用Yoast删除类别库:ok类别。php:
<?php get_header(); ?>
<?php get_sidebar(\'page\'); ?>
<div class="posts-list">
<ul class="categs-list">
<li class="<?php if(is_home()):?>current-cat<?php endif;?>"><a href="<?php echo get_permalink(get_option(\'page_for_posts\')); ?>" title="<?php _e(\'Voir tous les articles\', \'fc\'); ?>"><?php _e(\'Tous\', \'fc\'); ?></a></li>
<?php wp_list_categories(\'title_li=\'); ?>
</ul>
<?php pagination(); ?>
<?php
while ( have_posts() ) : the_post();
$category = get_the_category();
get_template_part( \'content-category\', $category[0]->slug );
endwhile;
?>
<?php pagination(); ?>
</div>
<?php get_footer(); ?>
函数分页():
function pagination()
{
if ( function_exists(\'wp_pagenavi\') )
{
echo "<nav class=\'pagination\'>";
wp_pagenavi();
echo "</nav>";
}
}
为什么分页会得到404?
编辑:mysite.com/blog/cat/feed
也不起作用
最合适的回答,由SO网友:Fabien Charrasse 整理而成
幸亏this 和this 我能够使解决方案适应我的问题。
Solution:
add_action( \'init\', \'wpa58471_category_base\' );
function wpa58471_category_base() {
add_rewrite_rule(
\'blog/([^/]+)/page/(\\d+)/?$\',
\'index.php?category_name=$matches[1]&paged=$matches[2]\',
\'top\'
);
add_rewrite_rule(
\'blog/([^/]+)/(feed|rdf|rss|rss2|atom)/?$\',
\'index.php?category_name=$matches[1]&feed=$matches[2]\',
\'top\'
);
}