WordPress.org

Ready to get started?Download WordPress

Forums

Developer's Custom Fields
Error on options_query using options_type 'posts' (2 posts)

  1. lowe_22
    Member
    Posted 2 years ago #

    Hi Steve,

    I've run into an interesting error when using a posts-populated select field. Once I create a new post in a custom post type, I get the following PHP warning:

    First parameter must either be an object or the name of an existing class in /Applications/MAMP/htdocs/.../developers-custom-fields/slt-cf-init.php on line 409

    I haven't thoroughly tested yet, but I think the issue is that as the post has not yet been saved we don't currently have a global $post set and so this function throws an error. It seems to be a fairly harmless error as the options_query is still displaying posts properly and I could easily suppress the it, but I thought it'd be worth while looking into, rather than attempting to cover-up the issue!

    Cheers,
    Olly

    http://wordpress.org/extend/plugins/developers-custom-fields/

  2. Steve Taylor
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Olly,

    Yeah, it looks like a minor error but worth fixing. I've pushed some changes to GitHub, see what you think:

    https://github.com/gyrus/WordPress-Developers-Custom-Fields/zipball/master

    To be clear, this is where you have the [OBJECT_ID] placeholder, which is replaced with the ID of the object being edited. So I guess you have a field applied to a custom post type, and that field has this placeholder, and when you create a new post of this type, you get the error? I think this would only occur when you hit "New post" - as soon as WP does an autosave, there's a post object. So whenever you go back to the post after that - and certainly after you Save Draft or Publish - the error won't be there.

    Let me know what you think.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic