This is a more detailed list of the issues I ran into when upgrading from WordPress 1.5.2 to 2.0.2, including the solutions I used.
- A rewrite rule that generates a URL like index.php?pagename=foo no longer works in all cases. The pagename must now include the parent page: ?pagename=bar/foo where ?pagename=foo used to work fine. I fixed this by editing all my rewrite rules.
is_single()
used to return true ifcount($posts) == 1
, this seems to have changed. Now it will not return true if a category_name or some other variable associated with a multi-item page is found by the rewrite rule processing code. I added a check for the count of the posts to my template code to work around this.is_page()
is apparently no longer based on on having apagename
in the URL. I wrote a plugin to set$wp_query->is_page = true
if there is a pagename token in the URL.get_the_excerpt()
fails and kills the page if it is requested for a “page” (not a post) in “the loop”. I fixed this by writing a plugin to do my own excerpt.- Some of my pages started showing the content from multiple items. I didn’t have time to dig into this to find the root cause, so I just threw a
break
into thewhile
loop in my page and single post templates. - If you use your blog prefix (/blog) as your category prefix (/blog/category-name), your blog rewrite rules will all break. I don’t like adding ‘category’ into the URL (/blog/category/category-name) as it feels like cruft to me. Unfortunately, even if you explicitly handle this in your rewrite rules and create a nice URL for WordPress to handle (/index.php?year=2006&monthnum=01&day=01&name=foo), the internal rewrite handler for WP will still look at the original URL, see the ‘blog’ prefix, and add ‘blog/2006/01/01/name’ to the query vars as a ‘category_name’. I was able to fix this with an ugly hack in a plugin.
- Using /blog as the root for the FeedLounge blog and redirecting to /index.php via the rewrite rules didn’t work anymore after upgrading. Eventually, I tracked the problem down to the 404 handling of the internal WP rewrite handlers. I commented out this section of code (classes.php, around line 84), and everything worked as expected again:
if ('404' == $qv['error']) {
$this->is_404 = true;
if ( !empty($query) ) {
do_action('parse_query', array(&$this));
}
return;
}
I think there may have been a few other minor issues, if I remember them I will update this post accordingly.
And here are the plugins I wrote to fix the issues I ran into:
- Fix Greedy Rewrite Category – unsets the category_name variable if the year variable is set.
- Page Friendly Excerpt – returns an excerpt from pages as well as posts.
- AK Is Page – sets
$wp_query->is_page = true
if there is a “pagename” in the URL.
These plugins can be downloaded from my WordPress page.
Much thanks Alex! I’ll check out these plugins in my blog at Plexav. Feel free to check it out if you have a moment. Again, thanks for all your efforts!
Ch-ch-ch-changes in WordPress 2.0.x New
Alex King schreibt über einige Details in WordPress 2.02, die für ihn interessant und wichtig sind. Zusätzlich liefert er in “Why You Should Upgrade Your WordPress Install” eine Erklärung für Upgrade-Willige dazu.
[…] UPDATE: Alex King offers an explanation of the changes in WordPress 2.0, and why you should upgrade WordPress for security reasons. […]
Thanks for the notes, I followed your lead and commented out the 404 code in classes.php to fix my mod_rewrite stuff, of course that broke 404’s. Argh…
[…] On the King Design web site I use a set of custom rewrite rules to hand off URLs to the WordPress back end. I never had any trouble with this through versions 1.5.x, but when I upgraded to 2.0.x, I ran into some trouble. […]
Great tip alex. I had been serving my “Archive page as a 404… Now I will send 200 ;).
solche Beiträge sind immer ser nützlich. Danke
[…] – Colorado passes a statewide smoking ban, whoohoo! I upgrade to WordPress 2.0.2 and release a few patch plugins. I begin development on PHP Tag Engine for Tasks Pro™ 1.7 and Tasks […]
thanks