Had a problem with my WordPress site crop up today that was driving me crazy. I was working on my Classes pages (page for each of the classes I teach that list the books and links that relate to that class). I have a primary page called Classes and then a secondary page for each class that has the info for that class on it.
While I was figuring out how to get the list of all the links and books that relate to the class onto the page I managed to break the site.
I set up my class pages and previewed one to get a 404 page not found error.
I checked the other pages on my site. Everything was okay except for the Classes subpages.
The link for the page looked okay, something like www.cornercode.com/classes/interface-design-ii-mm3001.
Enter the Permalink
WordPress generates a link for each page (remember this is a dynamic site, the pages don’t actually exist until WordPress generates them from the database). The link doesn’t actually matter as long as WordPress knows what info to put on the page from the info in the link.
The default link looks something like this:
Which tells WordPress to display the page with the id of 123.
I always set the link to something more human friendly (it’s also more search engine friendly) by using the permalink setting under Settings > Permalinks in the dashboard.
I went there now and put the links back to default. Tested all my pages. They all showed up.
So What Was Wrong With My Custom Permalinks?
I had to get on the web to find out. Great thing about WordPress is that a lot of people use it so a lot of people are asking questions and pointing out problems.
I searched for ‘WordPress permalinks for subpages don’t work’ and found several posts on the problem.
It seems that sometimes WordPress gets confused by the slug of the parent page. In my case, that is the word ‘classes.’ Why does that confuse WordPress? I’m not sure. I think it may be a reserved word that it uses for something else.
So, the solution? I had to change the slug of the parent page.
What is a slug? It’s the computer friendly name for a page. If my page title is Thing’s I like. The slug for that page will be something like things-i-like. It takes out the strange characters and the caps.
You can set your own slugs in the quick edit panel for the page (or on the edit page if you have the slug showing under screen options at the top).
I simply changed ‘classes’ to ‘classes-taught’ and suddenly WordPress could find my pages again.