Wordpress - 在子类别存档 URL 中显示父类别和子类别名称 [英] Wordpress - Show parent category AND subcategory name in subcategory archive URL

查看:29
本文介绍了Wordpress - 在子类别存档 URL 中显示父类别和子类别名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Wordpress category/subcategory 存档 URL 时遇到了一些问题.

I'm having some trouble with Wordpress category/subcategory archive URLs.

例如,我希望能够显示此存档:
http://faroutmagazine.co.uk/wp/track-of-the-day 同时保留其父级URL 中的类别,使其成为 http://faroutmagazine.co.uk/wp/music/track-of-the-day

For example, I want to be able to display this archive:
http://faroutmagazine.co.uk/wp/track-of-the-day while keeping its parent category in the URL, making it http://faroutmagazine.co.uk/wp/music/track-of-the-day

以前,我在访问 /music/track-of-the-day URL 时收到 404 消息这真令人尴尬……"(即使这是出现的那个)在 WP 管理部分类别下的查看选项中).

Previously, I was just getting a "This is embarrassing..." 404 message when accessing the /music/track-of-the-day URL (even though that's the one that was appearing in the View option under categories in the admin section of WP).

现在管理区域中的查看链接只向我显示 /track-of-the-day URL,这确实显示了很棒的类别帖子,但我希望它包含URL 中的父类别.

Now the View link in the admin area only shows me the /track-of-the-day URL, and this DOES display the category posts which is great, but I want it to include the parent category in the URL.

我可以对 functions.php 文件或我可以添加的任何插件做些什么来实现这一点吗?请记住,此站点上有多个子类别存档,并且它们都应在 URL 中包含父类别.

Is there anything I can do to the functions.php file or any plugins I can add to make this happen? Please bear in mind that there are multiple subcategory archives on this site, and they should all contain the parent category in the URL.

***更新:实际上,我现在使用 Pages 以不同的方式设置所有内容并在页面上显示类别档案,因为它占用了太多时间.不过还是谢谢你的回答.人们告诉我使用 %category%/%postname% 作为永久链接结构不正确 - 是的,这适用于 POST url 但不适用于子类别的存档类别,这实际上是我遇到的问题寻求帮助.如果有人能提供答案,我们将不胜感激,但我现在正在使用这种解决方法,因为这花费了太多时间试图弄清楚.

***UPDATE: I actually have just set everything up a different way now using Pages and showing category archives on pages as it's taking up too much time. Thanks for your answer though. People telling me to use %category%/%postname% as the permalink structure are incorrect - yes, this works for the POST urls but not for the archive category of the subcategory which is the problem I was actually looking for help with. If anyone can provide an answer, it would be appreciated, but I am using this workaround now as this was taking up way too much time trying to figure out.

推荐答案

出现这种情况是因为您在编辑条目时从右侧选项复选框中选择了类别和子类别.在每个条目中只选择子类别框,它将显示嵌套的 URL.

This happens because you chose category and subcategory from the right options tick boxes when editing the entry. Choose only the subcategory box in every entry and it will show the nested URL.

这篇关于Wordpress - 在子类别存档 URL 中显示父类别和子类别名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆