WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] CPT w/o title saving Auto Draft and meta upon creation (2 posts)

  1. Dankicity
    Member
    Posted 2 years ago #

    Not sure what's going wrong. If you go to create a new 'session' in my CPT and then leave the screen it creates an auto-draft that is unable to be deleted.

    Secondary problem which I think is directly related to the first is that all of the meta data comes prefilled right at creating the session.

    The CPT doesn't support titles, or anything else. It's basically just a meta box and custom taxonomy. Except I do set the title and then slug upon save. I'm not sure if that is why I can't delete the auto draft. Possibly the wrong hook that hits too early and triggers a save but I doubt it.

    Any hints?

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Note: this is being initialized in another class.

  2. Dankicity
    Member
    Posted 2 years ago #

    Once again, I find the answer a few minutes after I post here.

    Solved with snippet from the codex added to the wp_insert_post_data handler

    // If it is our form has not been submitted, so we dont want to do anything
        if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;

    pointed out by:
    http://wordpress.stackexchange.com/questions/26616/automatically-generate-custom-post-title-based-on-meta

    [Edit] Never noticed the 10 lines of code rule before. Sry about that.

Topic Closed

This topic has been closed to new replies.

About this Topic