0
我正在開發一個自定義wordpress主題(第一次),我創建了下面的文件,並且他們按照this教程正常工作。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(); ?>
我有兩個問題:
- 是否真的需要創建category.php或者我們可以使用的index.php爲同樣的目的顯示類別或標籤的帖子?
- 如果需要創建category.php,我是否還需要創建tags.php以及如何獲取這些文章?
404與您的模板文件無關。 WordPress在確定要使用哪個模板文件之前確定請求是否爲404。無論如何,如果'category.php'不存在,'index.php'將作爲一個catchall。 –