我注册一个新的自定义文章类型有:自定义永久链接
register_post_type('abcd_film',
array(
'labels' => array(
'name' => __('Films'),
'singular_name' => __('Film')
),
'description' => 'Manage the Films',
'supports' => array('title', 'editor', 'custom-fields',),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'films'),
)
);
我的WordPress位于(虚拟链路):
www.example.com/folder/wordpress/
我的永久链接设置为( “后名” 选项):
www.example.com/folder/wordpress/%postname%/
不过,我创建了自定义后键入“电影”与后名称为“苹果”下一个新的自定义后,该链接显示404未找到文件。该.htaccess
文件是由WordPress &由WordPress的书面当前内容写为:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /folder/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /folder/wordpress/index.php [L]
</IfModule>
# END WordPress
我是双phpinfo()
选中,mod_rewrite()
模块处于“加载的模块”部分。另外,我尝试刷新WordPress Admin > General > Permalink > Save Changes
中的固定链接设置。
404未找到仍然存在。我还可以做些什么?
试过如下:
添加
publicly_queryable
与值true
到选项阵列(它不是必需的,因为public
已经设置为true
和publicly_queryable
默认值是等于public
的值)add
with_front
with valuetrue
torewrite
sub-array(* this does not required,作为with_front
默认值是true
)后
register_post_type()
flush_rewrite_rules(false);
添加所有上述的尝试没有任何效果。缓存已被禁用&已刷新。
参考问题:
- WordPress Custom Permalink Structure for: Pages, Posts and Custom Post Types
- permalink structure for single-{post-type}.php in wordpress
- WordPress custom post type: Query by id works, by post_name doesn't
你试过把'flush_rewrite_rules(false); '刚才?另外,如果你改变永久链接结构会发生什么?你有''public_queryable'=> true,' –
添加''public_queryable'=> true'&'flush_rewrite_rules(false);'&清除缓存,404仍未找到... – Raptor
好吧..最后一件事我现在可以想到的是尝试''rewrite'=> array(“slug”=>“films”,“with_front”=> true),'与其他人合并。大约两周前我有同样的问题,但我不记得罪魁祸首是在哪里。并请将链接结构更改的结果发布到默认页面。 –