Blog

Wordpress 2.5 custom fields save incorrectly

Posted on May 16, 2008 in WordPress

This is my second post on problems I have encountered with WordPress 2.5. In the previous post, WordPress 2.5 - Where’s the category ID’s?, I explain how to track down the missing category ID’s on the manage categories screen. This post deals with a problem regarding custom fields.

Custom fields are a great way to add “custom” information to a post, for example urls of thumbnail images for posts, or to add special CSS classes to the markup. This post will show you that WordPress 2.5 does not save custom posts correctly, and I will also demonstrate how to prevent this from happening.

The Problem Explained

I create a new post named “Custom fields example”. Then I add three custom field values to that post:

After this I publish the post. This is where the problem comes in. The posts publishes and everything appears to be working fine. However when I go to the manage posts page things are not quite right.

In the image above you will see that WordPress has saved multiple versions of the post I just published (I marked these with red stars). It saves a “normal”, published version of the post. It also saves an unpublished version, along with three drafts. Note that WordPress will save a draft for each custom field you added to the post, and the each of these drafts will have saved a different one of the custom fields.

Now let’s take a look at the post I originally created (the one WordPress actually published). Only one custom field was saved. Look at the following image:

Only the last custom field was saved. Strange, right? I honestly don’t know why WordPress is doing this, but it is really inconvenient and makes a mess of your manage posts page when adding all those unnecessary drafts. But luckily the solution is dead simple.

The Solution

You can probably go and ad the custom fields one by one, saving the post after adding each one. But there is an even quicker solution. Just make sure you save the post at least once before you ad any custom fields. Then go back to the edit post screen and you can add as many custom fields as you want in a single go. Now, when you publish the post, all the custom fields will be saved correctly, and there won’t be any mysterious drafts on the manage posts screen.

In the images below I show that I created a post named “Custom Fields - Save your posts before adding!”, then saved the post once and after that I added three custom fields and published the post. When I go back to the edit post screen, all three custom fields have been perfectly saved. Take a look:

All there. Great! What’s more, when I take a look at the manage posts page:

No additional drafts were saved. Problem solved. I believe the WordPress gang will sort this problem out soon, but until then, this work-around is quick and painless enough.

So now you know how to prevent WordPress 2.5 from messing up your custom fields, just remember to save the post at least once before adding any custom fields, after that, go mad!

Share:
  • Digg
  • del.icio.us
  • MisterWong
  • Reddit
  • StumbleUpon
  • NewsVine
  • Technorati

Trackback URL

3 Comments:

  1. Rionya

    Rionya

    13-07-2008 at 5:43 pm // Permalink

    To solve this problem, you can add script below in wp-config.php.

    define( ‘AUTOSAVE_INTERVAL’, 60 ); // Autosave interval

  2. Rionya

    Rionya

    13-07-2008 at 5:44 pm // Permalink

    then, change 60 to higher number. example 60000.

  3. Die Hard Techie

    Die Hard Techie

    15-07-2008 at 2:41 am // Permalink

    ,
    I added the lines into my WP-CONFIG.PHP file but no use. I am still having the problem :(

Hi Stranger, leave a comment: