I upgraded my Wordpress installation to 2.1 the other day from 2.0. Normally I don’t bother with keeping my software so up-to-date but I had heard some good things about the newest version. After upgrading everything appeared to be working correctly except for some of my pages.
The link exchange page worked fine but the other pages returned a WP 404 message. I created a new page as a test to see if maybe I could just get away with redoing the 4 or so other pages from scratch but that didn’t work either.
What’s going on?
After some digging on the web I came across a wordpress support thread suggesting that the issue might be Kates Gasis’ Sideblog Plugin (which I’m using to populate the ‘distractions‘ list). I haven’t had a problem with this plugin in the past while this bug appears to be documented, I was using Kates’ 3.7 release which is supposed to address this issue (didn’t work for me.. and sorry no time to debug).
According to the above WP support thread, someone identified the cause of this issue to be centered around the default post category. Hmm that’s odd, I didn’t think pages had any association to categories…
Well I stand corrected. After looking at the wp_post2cat table, it appears that created pages are in fact associated with categories.
Running this:
SELECT p.post_title, p2c. *
FROM wp_posts p
LEFT JOIN wp_post2cat p2c ON p2c.post_id = p.ID
WHERE p.post_type = 'page'
Returned this:

How is this related to the default category? Well as we can see with the data, when a page is created it is associated with a category. Since that category association isn’t even viewable on the page management screens it logically must be automatically associating with the default category. As it turns out, this category_id is 11 which is why only the link-exchange page worked (I updated the test category_id after I discovered this issue which is why it originally didn’t work).
While we’re on the topic, does anyone know why pages are associated with categories? Can I just delete the entry for those associations from the wp_post2cat table?? Maybe this would be the fix Kates could build into her next revision (not an automatic delete but a button that executes the delete if the user is having problems).
Okay, so where were we?.. Ah right, so here’s the formula for getting a 404:
If you are running WP 2.1 AND you add a category to the sideblog that is assigned to an existing page OR if you have a sideblog category as your default posting category and you create a new page… you’ll get a 404.
A Quick Fix
Since we took the time to understand the problem so clearly our fix is pretty straightforward. Basically, we don’t want any of our existing or future pages to share a category association with a sideblog category.
First we need to stop future pages from breaking by changing the default post category to something other than our designated sideblog category(ies).
Secondly, we need to fix the old associations.. If you have access to your backend this is easy, just run something similar to this: (substituting ‘2′ for a non-sideblog category)
update wp_post2cat p2c
left join wp_posts p ON p.ID=p2c.post_id
set p2c.category_id = '2'
where p.post_type='page';
If that’s too intimidating for some of you then I’m afraid you’ll have to delete your old pages, change the default post category, and create new pages.
Good Luck!
5 Comments
Thank you for explaining this like a normal human.. I now know after all this time why I was getting page 404 on all new pages since upgrade…
I was using the same default category as one of my sideblogs….
Thanks again
Thank you for the kind words Bill, I’m happy my experiences offered some help to you.
Thanks for stopping by and leaving a comment!
A miracle… this was driving me insane! However, one other issue I’m having is that I have a list of the authors on the site. If I click an author that only has posts in the sideblog, it returns a 404! Any clues???
Hi Dianna, Glad this was helpful to you… Regarding your authors issue, the author archives uses the same filter as your main index so all ‘asides’ will be excluded from the page. (You probably already know that..) If no content exists then the is_posts() check fails and wordpress kicks out the 404 page.
You can create a custom authors template to return a custom query which includes your ‘asides’. See here for more information: http://codex.wordpress.org/Author_Templates
another solution is to create a new category for your asides, that isn’t the default, but after that you have to change the category of all posts
2 Trackbacks
[...] the problem: The 404s are caused by a conflict with the latest version of Sideblog (3.8). As i.ndustrio.us explains, when you create a page, Wordpress associates it w/the category you’ve chosen as your default [...]
[...] 3-4 derniers posts à cette catégorie. Et y a la solution propre qui est expliquée (mais en anglais) ici. Tags: plug in (pas de vote pour le moment) Loading … Pondu par Raph le Vendredi 6 [...]