简体   繁体   English

WordPress 类别永久链接设置问题

[英]WordPress Category Permalink Setup Issue

I have a new WordPress site that is migrating from an old Non-WordPress site.我有一个从旧的非 WordPress 站点迁移的新 WordPress 站点。 So the URL structure was different.所以 URL 结构不同。 I'm struggling to get it similar as it was before.我正在努力让它和以前一样。

The OLD URL structure OLD URL结构

https://test.com/[dynamic-category]/listing-name
IE: test.com/automotive/aaa-auto-company

And, the domain.com/automotive, was the archive page for all listings automotive.此外,domain.com/automotive 是所有汽车列表的存档页面。 Using the WordPress permalinks does not work with the "/%category%/%postname%/"使用 WordPress 永久链接不适用于“/%category%/%postname%/”

This is a custom post type/taxonomies and Has Archive enabled.这是一个自定义帖子类型/分类法并启用了存档。

The current URL structure is当前的URL结构是

https://test.com/listing-category/automotive <<-- Archive
https://test.com/listing/aaa-auto-company <<-- Listing

So in short, how do I get my custom post type to match the OLD URL structure所以简而言之,我如何让我的自定义帖子类型匹配 OLD URL 结构

https://test.com/automotive/aaa-auto-company

You can add a rewrite option to the options array when registering post types and custom taxonomies.注册帖子类型和自定义分类时,您可以向选项数组添加rewrite选项。

Example:例子:

https://test.com/listing-category/automotive <<-- Archive
https://test.com/listing/aaa-auto-company <<-- Listing
// .... registering listing post type
'rewrite'         => array(
    'slug' => 'listings'
);

Resulting in this:结果是:

https://test.com/listings/aaa-auto-company <<-- Listing

Then again in your taxonomy register options然后再次在您的分类注册选项中

// .... registering listing-category taxonomy
'rewrite' => array(
    'slug' => 'listing'
);
https://test.com/listing/automotive <<-- Archive

As far as getting them to be exatly the same?至于让他们完全一样? I don't think that's possible.我不认为这是可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM