【发布时间】:2014-10-07 16:30:52
【问题描述】:
我正在使用 add_rewrite_rule() 函数来修改我的 URL 结构。
我想使用 add_rewrite_rule 添加自定义规则,但只有在我的永久链接设置区域中选择了默认设置以外的设置时才会添加这些规则。
即在设置中有以下选项:
- Default http://localhost/wordpress/?p=123
- Day and name http://localhost/wordpress/2014/08/14/sample-post/
- Month and name http://localhost/wordpress/2014/08/sample-post/
- Numeric http://localhost/wordpress/archives/123
- Post name http://localhost/wordpress/sample-post/
- Custom Structure http://localhost/wordpress
因此,当我选择“默认”以外的其他选项时,我的 add_rewrite_rule() 函数可以工作,但是在选择“默认”时,该函数似乎不起作用。所以请建议我如何在任何情况下使用该功能。任何帮助都将不胜感激。
更新:
我认为问题出在:
当我使用它时,同时选择“默认”:
get_option('permalink_structure');
我什么都没有。
而在其他情况下,有一些值,例如:
/%postname%/
/archives/%post_id%
/%year%/%monthnum%/%postname%/
【问题讨论】:
标签: .htaccess url-rewriting wordpress permalinks