如何创建固定链接以显示特定类别页面 [英] How to create a permalink to display a particular category page
问题描述
在侧边栏中,我有两个类别:产品"和新闻".因此,我创建了两个类别文件category-product.php
和category-news.php
以不同的方式显示它们.
In my sidebar I have two categories: 'Product' and 'News'. So I have created two category files category-product.php
and category-news.php
to display them in a different way.
我的问题是:如何创建永久链接以显示这些单独的类别页面?默认的永久链接始终显示category.php
文件.有人可以提供一些想法吗?我是WordPress的新手.
My question is: how can I create permalinks to display these separate category pages? The default permalink always displays the category.php
file. Can anybody please provide some ideas? I'm very new to WordPress.
推荐答案
WordPress不仅基于永久链接结构,还基于请求解析结果选择模板.
当它确定您请求类别页面时,它将尝试在主题文件夹中找到category-$slug.php
文件.如果找不到此文件,它将尝试找到category-$id.php
,如果也找不到,则WP使用category.php
.
WordPress selects template based on request parse results, not only on permalink structure.
When it determines that you request category page then it tries to find category-$slug.php
file in theme folder. If this file is not found it tries to find category-$id.php
and if it also absent, WP uses category.php
.
因此,请仔细检查product
和news
是类别标签(不是标题).
并尝试使用debug-bar插件(http://wordpress.org/extend/plugins/debug-bar/).它可以显示请求参数.
So double check that product
and news
are categories slugs (not titles).
And try to use debug-bar plugin (http://wordpress.org/extend/plugins/debug-bar/). It can show request parameters.
这篇关于如何创建固定链接以显示特定类别页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!