WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Custom fields are duplicated every time a post/page is saved…

[Resolved] Custom fields are duplicated every time a post/page is saved…

  • Hi there,

    I’m encoutering the following issue:
    I’m using the “More Fields” plugin to provide user input.
    Every time the post or page is saved the key and value set in the MoreFields boxes are added to the WP ‘custom fields’ as a new custom field. This results in having a page or post with multiple ‘copies’ of the same key/value pair. This in turn results in multiple listings when using (for instance) wp_list_pages(“meta_key=somekey&meta_value=somevalue”).
    Furthermore: I can’t delete the extra ‘custom fields’. When deleting the message “Custom field deleted.” is shown but the same number of ‘Custom fields’ are present…

    Has anyone else encountered this behaviour before? (And knows a solution…)

    Thanks in advance for any input!

Viewing 6 replies - 1 through 6 (of 6 total)
  • I found the reason for this behavior: Since WP 2.6 the save_post hook is handled differently which causes WP to also check for the custom fields related to the revision and adding them (when obviously not found) to the ‘main’ post, thus duplicating the custom fields every time the post was saved…

    So it’s better to turn off WP’s native ‘revisions’…
    Turn off WP Revisions.
    …and use a dedicated plugin like “Revisions” if you want ‘revisions’.

    See also:
    http://alexking.org/blog/2008/09/06/wordpress-26x-duplicate-custom-field-issue
    and
    http://wordpress.org/support/topic/202040?replies=3

    Greetz!

    Isn’t the issue really that the “More Fields” plugin does not work correctly with WordPress 2.6? Evidently that is true for a number of plugins.

    @michaelh:

    Well, you could say that. However, the ‘issue’ started with WP changing the way the post is saved; including the revisions. This, because ‘revisions’ is a new feature, I’m sure was necessary, I don’t despute that. But the general opinion seems to be (Expressed by a number of (plugin) developers.) that that’s not the best way… Again, I’m no ‘plugin developer’ (I do mainly frontend design and development.) and do not have a well enough understanding about ‘everything in the WP core’. It’s not ‘my opinion’ and it’s not a criticism on WP. My post was for those that are encountering the same issue when using plugins that cause this; offering a (temp) workaround.

    Alex King has a good write-up for plugin authors looking to fix the problem (duplicate Custom Fields) with their plugin :
    http://alexking.org/blog/2008/09/06/wordpress-26x-duplicate-custom-field-issue

    Thanks for posting that link (Alex King’s directed at plugin author).

    For me the simple interim solution was: disable post revisions feature from WP, until either WP improves it, or until the plugin authors fix the plugin to be compatible with WP 2.6.

    How To Turn Off Post Revision In WordPress 2.6

    For me, this solution allowed plugins like Podpress, More Fields, and rc:Custom Fields GUI, to work again. Post Revisions feature is relatively unimportant (TO ME) compared to using these essential features of my site that my authors and readers have come to enjoy & expect.

    Sure, I would like the plugins to be updated, but in the meantime it’s important to keep my site working as nicely as it was working under WP 2.5

    Any improvement in this with version 1.2.10 of the plugin? Revisions are a necessity when building sites that need to “save clients from themselves”.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Custom fields are duplicated every time a post/page is saved…’ is closed to new replies.
Skip to toolbar