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

I created my own page template (for example, for the About page), added the name of the template inside the file and saved it. Then I tried to add the page to the admin wp console using this template. He said that the page was created successfully, but when I try to open it in the browser, it shows me a 404 error. What did I do wrong? Thank.

I forgot to say that I set permalinks as /% postname% / and then it gave me this error. If I do not use permalinks (default setting), it usually displays a page.

+3
source share
3 answers

I think the problem is not with your custom template, but with your permalink structure.

Not recommended to use /%postname%/- Codex quoting ;

Running permalinks with% postname% is strongly discouraged for performance reasons.

What is the slug ("cleaned" header used in the url) of the problem page?

+1
source

Friends, I made one change to the user template and it fixed the above problem.

Instead of require_once('./wp-blog-header.php');on a custom page to include a Wordpress theme,

I used this require_once('./wp-load.php');

This fixed the problem.

Please let me know if it works for you. I spent hours tracking and fixed this for theworksheets.com

+2

, Apache .

Also check to see if there is a file .htaccess(no file name with the extension "htaccess") in your WordPress root directory and 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
0
source

Source: https://habr.com/ru/post/1747265/


All Articles