Ch-ch-ch-changes in WordPress 2.0.x

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 if count($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 a pagename 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 the while 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));

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.