0
自定义后类型我试图创建一个名为“项目”的新的自定义类型,但我固定链接不工作。 这是我的代码:固定链接在WordPress的
function register_post_types() {
$labels = array(
...
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => false,
'rewrite' => array('with_front' => false, 'feeds' => false, 'pages' => false),
'supports' => array(
'title',
'editor',
'thumbnail',
'excerpt',
'comments'
)
);
register_post_type('projects', $args);
我手动更改固定链接(后名=>数值=>邮政名)获得了404网址http://website.com/projects/my-project均匀。
当调试(我用的是Dev4press招:http://www.dev4press.com/2012/tutorials/wordpress/practical/debug-wordpress-rewrite-rules-matching/)这里是我的结果:
<!-- Request: projects/my-project -->
<!-- Matched Rewrite Rule: projects/([^/]+)(/[0-9]+)?/?$ -->
<!-- Matched Rewrite Query: projects=my-project&page= -->
<!-- Loaded Template: 404.php -->
你能帮助我吗?
编辑: 奇怪的是,如果我更换
'rewrite' => array('with_front' => false, 'feeds' => false, 'pages' => false)
与
'rewrite' => array('slug' => 'p', 'with_front' => false, 'feeds' => false, 'pages' => false)
我可以访问http://website.com/p/my-project/,但如果我改变与 '项目' 蛞蝓我无法访问http://website.com/projects/my-project/ :(
谢谢卡希夫,不幸的是我记录我重写规则,每当我与冲洗重写规则修改我的源代码()函数和我有同样的问题。 – ncrocfer