我正在开发一个自定义的wordpress主题(第一次),我已经创建了下面的文件,他们工作很好,遵循本教程。
index.php
header.php
footer.php
single.php
sidebar.php
现在的问题是当我在主页上点击一个类别名称时,它显示我404错误,我试图创建category.php但仍然是同样的问题。这是我的index.php,我用它来表示category.php
<?php get_header(); ?>
// other html stuff and loop
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php endwhile;?>
<?php endif; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
我有两个问题:
不,在WordPress主题中不需要有category.php
文件。在WordPress Works中找到模板层次结构的链接。
https://developer.wordpress.org/themes/basics/template-hierarchy/#类别
您可以看到,如果主题中没有category.php
文件,那么它最终会返回到index.php
。