wordpress中单个{post-type} .php的永久链接结构 [英] permalink structure for single-{post-type}.php in wordpress

查看:72
本文介绍了wordpress中单个{post-type} .php的永久链接结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了多种方法将自定义帖子类型显示为单{{post-type},最后,一旦我使用它,它就可以很好地工作:

I have tried many ways to display my custom post type as single-{post-type} and finally it works nicely once i used:

'rewrite'=>否,

'rewrite'=> false,

在此之前,我使用了

'rewrite'=> array('slug'=>'custom-post-type')

'rewrite' => array( 'slug' => 'custom-post-type' )

但从不为我工作.不知道我在哪里犯错了.现在,我应该感到高兴,因为它的工作没有任何错误.但是对于永久链接,请稍加困惑,因为其显示方式:

but never works for me. Don't know where i made mistake. Right now i should feel happy cos its working without any error. But have a small confusion for the permalink because its display:

localhost/myblog/?news = breaking-news 而不是:localhost/myblog/news/breaking-news

localhost/myblog/?news=breaking-news instead of: localhost/myblog/news/breaking-news

任何人都请给我一些想法,例如:

anyone please provide me some idea how to get link like:

localhost/myblog/news/breaking-news

localhost/myblog/news/breaking-news

已选择我的永久链接结构:> http//myblog/sample-post/

my permalink structure selected: > http//myblog/sample-post/

推荐答案

您第一次做对了...

You had it right the first time...

'rewrite' => array('slug' => 'custom-post-type')

如果它不起作用,请尝试通过转到设置">永久链接"并单击保存"按钮来清除重写缓存.

If it's not working then try clearing your rewrite cache by going to Settings > Permalinks and clicking the save button.

这篇关于wordpress中单个{post-type} .php的永久链接结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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