Sergei Basharov
Sergei Basharov

Reputation: 53850

Wordpress throws 404 when I try to use a custom template page

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.

Upvotes: 3

Views: 3886

Answers (3)

Deepan Prabhu Babu
Deepan Prabhu Babu

Reputation: 912

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

Upvotes: 3

TheDeadMedic
TheDeadMedic

Reputation: 9997

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;

# 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

Upvotes: 0

TheDeadMedic
TheDeadMedic

Reputation: 9997

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;

Starting Permalinks with %postname% is strongly not recommended for performance reasons..

What's the slug (the 'sanitized' title used in the URL) of the problem page?

Upvotes: 1

Related Questions