--- title: WordPress全部文章分类页面 createTime: 2021/09/30 tags: - Wordpress --- 1. 复制一个 page.php 为 catlist.php ```bash cd usr/wordpress # 自己的WordPress目录 find . -name page.php # 找到自己主题对应的路径 cd YourThemePath cp page.php catlist.php ``` 2. 在 catlist.php 最前添加代码 ```php ``` 3. 在 catlist.php 中找到``并在其后添加如下代码 ```php false,'parent'=>'0',)); if(!empty($taxonomies)){ foreach($taxonomies as $category){ if($category->name != '未分类'){?>

term_id)?>>name?>

'; //获取二级分类 $cats=get_terms('category',array('hide_empty'=>false,'parent'=>$category->term_id,)); if(!empty($cats)){ foreach($cats as $cat){?>

term_id)?>>name?>

'; //获取三级分类 $terms = get_terms('category',array('hide_empty'=>false,'parent'=>$cat->term_id,)); if(!empty($terms)) { foreach($terms as $term){?>

term_id)?>>name?>

'; } } echo ''; } } } ?>

未分类

``` 4. 保存模板,新建空白页面,页面模板选第二步 Template Name 后的名字,这里是 Category 5. 保存并发布,在菜单添加该页面即可