php – How to use multiple 404 Error Pages in WordPress


i have a question and couldn’t find a solution for it.

We have a WordPress page where the client wants multiple error pages.

1 error page is in the usual normal 404.php for the custom theme which we created. Now i wanted to add multiple error pages with different styling and html structure.


localhost/blog/{post-name} -> if this post name is not found load me the post-404-error.php

localhost/service/{service-name} -> if service was not found load the service-404-error.php

i couldn’t think of a good solution how to get it done the right and save way.

i thought about changing the .htaccess like here described :

but if permalinks are saved the .htaccess is rewritten and my changed will be gone there also i didn’t know how to put the correct error documents inside ( my rewriting htaccess knowledge is not the best) i thought there could be a coded way with php/js something?

i also thought about some complicating check if this url is called and then check if is_404() but i guess its to complicated

thanks in advance for any help and tips 🙂

Jaba 2 months 2022-10-03T09:01:37-05:00 0 Answers 0 views 0

Leave an answer