WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
function draftpost(){
    global $wpdb;
    $prefix = $wpdb->prefix;
    $wpdb->query("UPDATE ".$prefix."posts SET post_status='draft' WHERE LENGTH( post_content ) <500");
add_action('publish_post', 'draftpost');

This code is working Fine for changing Published Items to Draft.

Issue is that this code removes my Custom Menu and make all Items in Menu to PENDING. How can I solve this?

share|improve this question
are you trying to change all existing posts with "less content" to draft, or just the post that is being published? – aaronwaggs Jan 7 '13 at 5:50
I am trying to change all posts with less content to draft and this action happens when user is posting new post. – Naveen Sharma Jan 7 '13 at 7:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.