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

Posted in: WordPress

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));
    }
    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.

Popularity: 6% [?]

Posted March 13th, 2006 @ 10:52 AM

9 Replies

  1. Kenneth Stein adds this Comment:

    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!

    March 13th, 2006 at 4:39 pm

  2. einfach persoenlich Sideblog adds this Trackback:

    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.

    March 14th, 2006 at 12:49 am

  3. Lorelle on WordPress » WordPress 2.0.2 Update adds this Pingback:

    [...] UPDATE: Alex King offers an explanation of the changes in WordPress 2.0, and why you should upgrade WordPress for security reasons. [...]

    March 15th, 2006 at 4:07 am

  4. Pete Prodoehl adds this Comment:

    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…

    March 15th, 2006 at 7:21 am

  5. alexking.org: Blog > WordPress 404s adds this Pingback:

    [...] 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. [...]

    May 31st, 2006 at 5:25 pm

  6. ShoeMoney adds this Comment:

    Great tip alex. I had been serving my “Archive page as a 404… Now I will send 200 ;) .

    June 8th, 2006 at 4:19 pm

  7. Yankee adds this Comment:

    solche Beiträge sind immer ser nützlich. Danke

    November 14th, 2006 at 7:33 am

  8. 2006 in Review | alexking.org adds this Pingback:

    [...] – 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 [...]

    April 18th, 2007 at 11:41 am

  9. toxa adds this Comment:

    thanks

    April 14th, 2008 at 5:43 am

Add a Comment

Please note: Use of a non-personal web site or blog in the field below and/or comments that are off-topic, personal attacks, or support requests will likely be removed at my discretion.

Note: This post is over 3 years old. You may want to check later in this blog to see if there is new information relevant to your comment.

Why You Should Upgrade Your WordPress Install » « Around the web

About This Site

This is the personal web site of Alex King, a web developer in Denver, Colorado USA. More...


Crowd Favorite

Crowd Favorite is my software and web development business.

We build web applications, design and develop custom WordPress themes and plugins, and build custom sites using WordPress as a CMS.


I also have a tumblog that aggregates my online content from other services (Twitter, Flickr, del.icio.us. etc.).

America - america09.com

Ads

web design services