我的第一个CPT完全按照预期保存其URL。然而,我已经花了2天的时间让我的第二个和第三个自定义帖子类型URL正确重写。事实上,它们确实在编辑中按预期保存。php如下所示:
www.domain.com/things/postname/
However it is 404ing when I view the page. 我用过
global $wp_rewrite;
$projects_structure = \'/%things%/\';
$wp_rewrite->add_rewrite_tag("%things%", \'([^/]+)\', "things=");
$wp_rewrite->add_permastruct(\'things\', $projects_structure, false);
Why won\'t the other CPT URL\'s rewrite? 对于我的“食物”CPT,我正在使用
\'rewrite\' => array(
\'slug\' => \'food\',
\'with_front\' => false,
\'feed\'=> true,
\'pages\'=> true
),
也尝试过
global $wp_rewrite;
$projects_structure = \'/food/%food%/\';
$wp_rewrite->add_rewrite_tag("%food%", \'([^/]+)\', "food=");
$wp_rewrite->add_permastruct(\'food_pt\', $projects_structure, false);
全新WP安装,我已检查我的htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
我已手动刷新\\u rewrite\\u rules();我的设置->永久链接结构是
/%year%/%postname%/
我已经阅读了谷歌能给我的一切,只是不明白而已。任何帮助都会很好。