You are right. That’s because the Plugin loads the defined 404 page, which exists and therefore is_404() correctly is false. In my tests I’ve tried to set is_404() to true after loading the page but that causes problems with some themes that use is_404() to show their default 404 error although a page was loaded successfully.
If you need to add functionality in case of a 404 error you can use the 404page_after_404 hook. Is that OK for you or do you think there has to be an option to switch is_404() to true if needed?
Peter
Thread Starter
Anonymous User 14379775
(@anonymized-14379775)
I do not know if that’s a problem for other people, but I’ve tried to enqueue some additional CSS only on 404 page specifically and discovered that is_404() was not working.
But I simply used another conditional tag for this purpose, like
is_page(‘slug’) and achieved the same result as was planned.
-
This reply was modified 9 years, 6 months ago by
Anonymous User 14379775.
You do not need this at all. The plugin adds a class error404 to the body tag. Use this for styling.
Thread Starter
Anonymous User 14379775
(@anonymized-14379775)
Not quite so.
I add additional CSS File (using wp_enqueue_style) so that it appears only on 404 page and not on the entire site.
OK, I think the additional CSS should not be worth mentioning for the page size, but if you’d like to only load it on the 404 page I’m glad you solved it.