从 WordPress 中的 URL 中删除分类库
我在从 WordPress 的 URL 中删除分类库时遇到了一些问题。我尝试了不同的方法,但没有一个有效。
register_taxonomy('project_category','projects',array(
'labels' => $labels,
'show_ui' => true,
'rewrite' => array(
'slug' => 'project-category',
'with_front' => false,
'hierarchical' => true),
'hierarchical' => true)
);
我目前看到的网址如下: http://mysite.com/project-category/project1我希望它是这样的:http://mysite.com/project1。
我尝试将 slug 重写为“”而不是“项目类别”,但这弄乱了我的所有其他页面,重定向到 404 页面。
I have a little problem with removing the taxonomy base from the URL in Wordpress. I tried different approaches but none worked.
register_taxonomy('project_category','projects',array(
'labels' => $labels,
'show_ui' => true,
'rewrite' => array(
'slug' => 'project-category',
'with_front' => false,
'hierarchical' => true),
'hierarchical' => true)
);
I currently see the URL like this : http://mysite.com/project-category/project1 and i want it to be like this: http://mysite.com/project1.
I tried to rewrite the slug to '' instead 'project-category' but that messed with all my othr pages, redirecting to a 404 page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是我如何设法将我的网址重写为特定网址的方法。
还可以查看一些教程,有时您可以获取位&主题片段。
Heres how I've manage to get my url to rewirte to a spcific url.
Also check out some tutorials and sometimes you can grab bits& pieces from theme.
尝试这个
只需将其放入
wp-content/plugins
并激活。它正在被添加到 WP 存储库中。Try this
Just drop it into
wp-content/plugins
and activate. It is in the process of being added to the WP repository.使用此插件 https://github.com/alexvornoffice/remove-taxonomy-base-slug< /a>,
这是做什么的?
它从所有分类中删除基本 slug,并检查该 slug 是否与帖子类型 slug 相同,并以这种方式重写规则,以便分类法 slug 比帖子类型 slug 具有更好的优先级。
use this plugin https://github.com/alexvornoffice/remove-taxonomy-base-slug,
what this does?
It removes base slug from all taxonomies, and check if the slug is the same as post type slug, and rewrites the rules in the such way so the taxonomy slug will have a better priority over post type slug.