【问题标题】:Display category AND sub category in post URL - Wordpress在帖子 URL 中显示类别和子类别 - Wordpress
【发布时间】:2021-02-24 08:43:58
【问题描述】:

我需要自定义我的帖子 URL (wordpress)。

我使用父类和子类。

如果我从子类别发布帖子,则 URL 为: domain.be/category/subcategory/post-title

但如果我选择子类别和父类别,则 url 为: domain.be/category/post-title

如果我同时选择两者,我需要带有 cat 和 subcat 的 url。

在 Wordpress BO > 设置 > 永久链接:

我不想使用插件

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    首先,在修改 url 永久链接结构时,最好使用 Wordpress flush_rewrite_rules() 函数刷新重写规则。

    删除重写规则,然后重新创建重写规则。


    您实际上是在正确的轨道上,确实需要在您的自定义永久链接结构中使用 /%category%/%postname%/

    为了本示例的目的,让我们声明两个类别,父类和子类,FruitsTomatoes

    Fruits
    └── Tomatoes
    

    Wordpress 使用分层字母顺序来选择将在 url 永久链接结构中使用的类别。 默认情况下,Wordpress 每个级别不能显示超过 1 个类别。

    Behaviour Description
    Possible eg: domain.com/parent/child/grand-child/my-first-post/
    NOT Possible eg: domain.com/parent-1/parent-2/my-first-post/

    如果我们希望我们的网址为 domain.com/fruits/my-first-post/,我们需要至少选择 fruits 类别。

    如果我们希望我们的网址为domain.com/fruits/tomatoes/my-first-post/,我们需要选择tomatoes 类别ONLY

    最后,您只需取消选择与您的子类别相关联的顶级类别,您就可以开始了。

    【讨论】:

      猜你喜欢
      • 2019-09-21
      • 1970-01-01
      • 2016-04-11
      • 1970-01-01
      • 1970-01-01
      • 2016-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多