Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

how to stop "auto-draft" & auto save in wordpress ..

how to stop "auto-draft" & auto save in wordpress ..

i see many posts in table wp_posts ..

3 Answers

You can't fully disable it without doing some pretty hacky work arounds but you can set a really high interval for the auto-save by adding some code to wp-config: http://codex.wordpress.org/Editing_wp-config.php#Modify_AutoSave_Interval

define('WP_POST_REVISIONS', false);

define('AUTOSAVE_INTERVAL', 9999 );

The above code will stop revisions from being kept, and will autosave every 9999 seconds (166.65 minutes). Just remember to click on the save draft button every so often.

still add more posts to wp_posts

you try to refresh post-new.php every second and see more post_status ( auto-draft )

still no results ..

i want to disable completely all drafts

Are you trying to completely disable all of the drafting functionality as well? I'm not sure I completely understand what your goal is.

yes i want to disable all of the drafting functionality ..

i do sql query every time after refresh post-new.php

""" DELETE FROM wp_posts WHERE post_status LIKE 'auto-draft'; DELETE FROM wp_posts WHERE post_status LIKE 'inherit'; ALTER TABLE wp_posts AUTO_INCREMENT =1; """

I'm not sure about the feasibility of disabling that, it looks like it is intended for a very specific reason:

"Auto-drafts exist because of the fact that multiple users can create new posts at the same time. If two people enter post-new at roughly the same moment, then have their first autosaves occur nearly simultaneously, then there is a race condition that can cause one of them to get back the wrong post ID, which will cause a post to be overwritten/lost when they then continue editing the post.

The auto-draft creates the post and gets the ID of the new post before the editing screen is displayed, thus preventing two simultaneous authors from accidentally having the same post ID in the data in their browser."

Source: http://stackoverflow.com/questions/10234271/wordpress-auto-draft-disabling

There is a plugin you can use to save yourself form doing those queries too:

https://wordpress.org/plugins/wp-clean-up/

that solution you provide a little good but what about AUTO_INCREMENT =1; still every draft +1 and manual query also with interface .