删除 WordPress 自定义分类库
我在 WordPress 3.0.4 中使用自定义分类
有谁知道如何从 URL 中删除分类基础吗?
我见过一些插件可以为类别和标签执行此操作,但不能为自定义分类法执行此操作。
例如,我有一个名为“城市”的自定义分类法。我希望我的 URL 结构为 mydomain.com/newyork 而不是 mydomain.com/cities/newyork
是否有我可以使用的功能或东西?
I am using custom taxonomies with WordPress 3.0.4
Does anyone how to remove the taxonomy base from the URL?
I have seen plugins that do it for categories and tags, but not for custom taxonomies.
For example, I have a custom taxonomy called 'cities'. I would like my URL structure to be mydomain.com/newyork instead of mydomain.com/cities/newyork
Is there a function or something I can use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@iamfriend 和 @Carson - 将 with_front 参数设置为 false(或 true)将不允许您从 URL 中删除“城市”。
@iamfriendly and @Carson - setting the with_front argument to false (or true for that matter) will not allow you to remove 'cities' from the URL.
http://codex.wordpress.org/Function_Reference/register_taxonomy
如果你看那里,你会看到一个“重写”论点,你可以看到它是正确的。此参数还采用“with_front”参数,默认为 true...这就是为什么您拥有分类法的“front”。
创建自定义分类法时,根据需要设置这些参数,然后您就可以离开了:)
如果您设置了此自定义分类法,那么您就可以实际设置 with_front false 参数将阻止这种情况发生。如果你看这里:
http://codex.wordpress.org/Function_Reference/register_taxonomy
你会查看“rewrite”参数,在其下方,您将看到“with_front”部分。
http://codex.wordpress.org/Function_Reference/register_taxonomy
If you look there, you'll see a 'rewrite' argument which you can see to true. This argument also takes an argument of 'with_front' which defaults to true... which is why you have the 'front' of the taxonomy.
When creating your custom taxonomy, set those arguments as you wish, and you'll be away :)
If it is you who has set up this custom taxonomy, then you're able to actually set the with_front argument to false which will stop this happening. If you look here:
http://codex.wordpress.org/Function_Reference/register_taxonomy
You'll see the 'rewrite' argument and just below that, you'll see the 'with_front' part.