[Resolved] Custom 404 page
This both server env. and theme dependent. That said look for a file named 404.php in your theme (add a div with some text to test if this is the file in use) and note that direct edits to theme files are lost on theme updates, so a Child Theme is recommended.
Your theme should have a 404.php template.
If not, then you can add one to your child theme.
Have a look at the 2012 theme it has one.
Just looked and it is in my theme, not the child. If I copy it to the child, that will suffice as a backup. But if I want it to call it from the child theme, which file would I edit?
I thought that what happens is that if you have a template file in your child them then that’s the file that WP will use if it needs it. So I would say just edit the file that you copied to the child theme and be done with it.
Martin is correct. When making a child theme, if you want to edit a template from the parent, you simply copy the partent template to your child theme and then make your changes there.
I often do this with the page.php. I copy the page.php template to my child theme, remove the comments from that template and comments are gone on my child theme.
You can do this with any template from the parent except the functions.php. That template is a little bit trickier.
Thanks. Child themes are very new to me. 5 years go, when I had 20-30 WP sites, we had a theme and that’s it. Upgrades were hell as I’ have to upgrade then edit certain files from a backup of the old.
So you say to copy 404.php to my child, edit, then that is the file WP will use … seems simple enough. That means the header.php file I need to edit should be in the child, not the main theme. Glad I found that out!
You could edit any of the files in the main theme and that would work fine but then, what would be the point of a child theme? WordPress looks for files in the child theme first. If it doesn’t find the file it is looking for there, it will trn to the main theme.
As Christine Rondeau said, the function.php file is the exception.
Well, since I don’t know anything about child themes, as I said, I thought there were files that overwrote those of the main theme. I don’t fully understand the thought process but I’m thinking quick. One file in one place makes more sense to me than superfluous files taking up file space. I’m sure there is a reason behind the whole idea. Someday I’ll learn it
The really neat thing about child themes is that you can make quite comprehensive theme modifications using CSS and modifying one or two template files. When/if the theme is updated you can happily let update and not lose any of your modifications.
There are themes out their that are intended to not use child themes like Underscore and Bones to name a couple, but having tried them, I still prefer the child theme route.
I came to realize that the child is where you make all design installs and edits plus copies of files you change in WP. This way an update doesn’t overwrite your theme. Right?
Yay I’m learning again! Makes a lot of sense. I edited the 404.php in my child and all is fine.
I’m wondering …. if I edit the theme in the parent and rename that file in the child … to test out a change in the theme, then if correct, upload it, will that work?
Sounds like you got it. What I would do is copy a file from the parent and then fiddle with that file. No need to tamper with the parent theme files at all. If after your edits things don’t go as planned delete the child theme copy and wordPress will us the original file again.
If I am doing this and want to keep a hold of my edits to the copied file I put an uppercase X in the file name to stop it being called. So say I want to tinker with header.php I cop that to the child directory and hack away. If I don’t finish what I am doing or can’t get it right straight off then I name that file Xheader.php and WP will use the file in the parent.
Works for me
- The topic ‘[Resolved] Custom 404 page’ is closed to new replies.