[英]Category page in wordpress
I am developing a custom wordpress theme ( first time) , I have created below files and they work fine by following this tutorial. 我正在开发自定义的wordpress主题(第一次),我已经创建了以下文件,并且通过遵循本教程可以正常工作。
index.php
header.php
footer.php
single.php
sidebar.php
Now issue is when I click on a category name at home page it show me 404 error, I tried to create category.php but still same issue. 现在的问题是,当我单击主页上的类别名称时,它显示404错误,我尝试创建category.php,但仍然是同样的问题。 here is my index.php which I used for category.php
这是我用于category.php的index.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(); ?>
I have two question: 我有两个问题:
No, it is not required to have category.php
file in a WordPress theme. 不,不需要在WordPress主题中包含
category.php
文件。 You can see following link for finding out template hierarchy in WordPress works. 您可以在WordPress作品中看到以下链接,以了解模板层次结构。
https://developer.wordpress.org/themes/basics/template-hierarchy/#category https://developer.wordpress.org/themes/basics/template-hierarchy/#category
You can see that, if there is no category.php
file in theme, it ultimately falls back to index.php
. 您可以看到,如果主题中没有
category.php
文件,则最终它会退回到index.php
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.