Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

How to manage error numbers inside Wordpress?

         

toplisek

4:52 pm on Jan 8, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have seen error management is managed using specific file. But I have an issue how to manage different number of error like 404....Is it possible as I do not like plugins management.

not2easy

5:08 pm on Jan 8, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What happens when a 404 is generated currently? I ask because in most WP themes, there is a file named 404.php that is posted in response and it "can" be edited. Meaning that if you understand how to edit the php page it can be edited. Keep a copy of the original if you do that. Your "new" 404.php file will very likely be overwritten on the next update and you would need to compare your original (pre-edited) page to see whether uploading an edited version will still work or whether there are other factors to update in your edited version.

You can create other error pages, but they will need to be declared in .htaccess because WP does not deal with server errors other than 404.

toplisek

5:18 pm on Jan 8, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You mean I place the same content and my number inside PHP file like: 402 and it will be shown inside WP when an error is thrown?
Can be placed loop inside functions.php and if (400) {"is_help_page_error_400_0_1");}
elseif (401) {"is_help_page_error_401_0_1");} ....
and connect HTACCESS to those files?
I do not see any connection inside HTACCESS inside WP and file named 404.php.

not2easy

5:45 pm on Jan 8, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



No, WP will not respond to a 402 server error. If you need a specific error page, one that is not 404, you create an actual page, then you add that information to your htaccess file so that when the server has a 402 error, it will display your page.

After you create and upload your page you add a line to your .htaccess file, something like:
ErrorDocument 402 /402.php 
(assuming you name your page "402.php") But it can be "402.html" or whatever you like to name your error page, which would change what you tell the server to show for that error. It could be:
ErrorDocument 402 /my402page.html 


If you wish to try some test with your theme's functions.php file that is a different method which I cannot guess whether it will work as expected or not, sorry. It would seem to assume that WP is receiving server errors which normally it does not.

toplisek

10:07 am on Mar 16, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thank you for the message!

numanwaris

5:43 pm on Apr 19, 2021 (gmt 0)



your smart custom 404 error page:
handy plugin allows you to easily create your own 404 error page without any effort and it works with almost every theme.
Create your custom 404 error page just like any other page using the WordPress Page Editor. Then go to ‘Appearance’ -> ‘404 Error Page’ and select the created page as your custom 404 error page. That’s it!

lammert

7:23 pm on Apr 19, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why use a plugin to do something as simple as creating a 404 page? Wordpress treats a file with the name 404.php in the base directory of the active theme automatically as the 404 page. Every extra plugin you install is an additional potential security issue.

not2easy

7:34 pm on Apr 19, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Every extra plugin you install is an additional potential security issue.
The mentioned plugin has less than 1000 installs and is only valid up to 5.6.3, (not being kept up to date). So why add to your maintenance load for something anyone can do without a plugin?

toplisek

9:17 am on May 4, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If plugin creates additional browser requests, it is a problem. It is a personal decision if you like to use without plugin. Usually, I do not use plugins as it a better way to code without browser requests. In example: just one plugin for a contact pages can create browser requests.

Thank you for all replies.