当我尝试使用自定义模板页面时,Wordpress 抛出 404
我制作了一个自定义页面模板(例如,关于页面),在文件中添加了模板名称并保存。然后我尝试使用该模板在 wp 管理控制台中添加一个页面。它说页面已成功创建,但是当我尝试在浏览器中打开它时,它显示 404 错误。我做错了什么? 谢谢。
我忘了说我将永久链接设置为 /%postname%/ 然后它给了我这个错误。如果我不使用永久链接(默认设置),它会正常显示页面。
I made a custom page template (for example, for About page), added Template Name inside the file and saved that. Then I tried to add a page in wp admin console using that template. It said that the page had been created successfully but when I try to open it in browser, it shows me 404 error. What did I do wrong?
Thanks.
I forgot to say that I set up permalinks to be /%postname%/ and then it give me that error. If I use no permalinks (default setting), it show the page normally.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为问题与您的自定义模板无关,而是与您的永久链接结构有关。
确实不建议仅使用
/%postname%/
- 引用自 Codex;问题页面的 slug(URL 中使用的“已清理”标题)是什么?
I think the problem is nothing to do with your custom template, but your permalink structure.
It's not really recommended to just use
/%postname%/
- quoting from the Codex;What's the slug (the 'sanitized' title used in the URL) of the problem page?
确保编辑配置文件后已重新启动 Apache。
另请检查您的 WordPress 根目录中是否有一个
.htaccess
文件(无文件名,扩展名为“htaccess”),并且它包含:Make sure you've rebooted Apache after editing the config file.
Also check there is a
.htaccess
file (no filename, with an extension 'htaccess') in your WordPress root, and that it contains;朋友们,
我对自定义模板进行了一次更改,它解决了上述问题。
而不是
require_once('./wp-blog-header.php');
在包含 WordPress 主题的自定义页面中,我使用了这个,
require_once('./wp-load.php');
这解决了我的问题。
请告诉我它是否适合您。我花了几个小时为 theworksheets.com 跟踪和修复这个问题
Friends,
I made a single change to the custom template and it fixed the above issue.
Instead of
require_once('./wp-blog-header.php');
in the custom page for including Wordpress theme,I used this,
require_once('./wp-load.php');
That fixed me the problem.
Please let me know if its working for you. I spent hours tracking and fixing this up for theworksheets.com