Different 404 Pages Depending on what parent page is being hit

[ad_1]

I inherited a site from a previous guy, that is basically like 2 different sites. Instead of splitting them up as two different wordpress installs on a different sub directory, this guy just made a couple parent pages and nested everything for Site A under that parent, and everything for Site B under that parent. Then he went off and installed a plugin to change the logo based on what parent or sub page is being visited.

I need to achieve something similar but with 404 pages. I need two different 404 pages. One for site A and one for site B. So if someone visits [https://website.com/siteA/doesntexist]) they are served up 404A page. And if someone visits [https://website.com/siteB/doesntexist]) they are served up 404B page.

Anyone know of a way to do this? I was trying to mess with the 404 php file but have not been successful yet. Personally, had I created this from the start, both of these sites would be on separate installs. Not an option at the moment though. Open to any other suggestion other than that.

[ad_2]
1 Comment
  1. I would just get the current path from the $_SERVER var and check which parent it starts with and use that conditional to render a different partial in the 404.php file of the theme

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer