Force Imported WordPress Posts to Save as Draft (Every Time)

wordpress import

Want to import a bunch of posts but don’t want them to go live by accident? Let’s make WordPress put every imported post into Draft automatically. This way you can double-check titles, images, links—everything—before you publish.

You’ll learn:

  • Why this is useful
  • How to install the WordPress Import tool (the official one)
  • Where to put the code
  • What every line of the code means
  • How to test it, plus quick fixes if something seems off

Why you’d want imports to be Drafts

Most people import data when they change WordPress domains. But whatever your reason, this guide will work.

  • Safety first: Big imports can contain mistakes. Drafts keep things private until you review.
  • Time to clean up: Fix categories, tags, featured images, and links without any pressure.
  • No surprises: Nothing shows up on your site until you click Publish.

First: Install the WordPress Importer

wordpress-importer
  1. In your WordPress dashboard, go to Tools → Import.
  2. Find WordPress in the list.
    • If you see “Install Now”, click it.
    • If it’s already installed, you’ll see “Run Importer.”
  3. When it’s installed, click Run Importer to use it.

The Code (copy-paste ready)

Note: Some security plugin, e.g. Defender has the option disable theme editor feature. If you can’t edit, you can either disable that feature or go to your server’s file manager or FTP, and edit theme’s fumction.php.

  • In your dashboard, go to Appearance → Theme File Editor.
  • Pick your Child Theme (recommended). You may create
    • Why child theme? If you update/switch the main theme, your changes won’t vanish.
  • Open functions.php.
  • Paste the cod snippet at the very bottom, after any existing code.
add_filter( 'wp_import_post_data_processed', 'force_all_imports_to_draft_processed', 9999, 1 );
function force_all_imports_to_draft_processed( $post ) {
    if ( is_array( $post ) ) {
        if ( isset($post['post_type']) && $post['post_type'] === 'attachment' ) {
            return $post;
        }
        $post['post_status'] = 'draft';
    }
    return $post;
}
  • Click Update File.

Explanation Of Code What We Are Doing

add_filter( 'wp_import_post_data_processed', 'force_all_imports_to_draft_processed', 9999, 1 );
  • “Hey WordPress, when the importer is about to save a post and has already prepared its data (wp_import_post_data_processed), run my function named force_all_imports_to_draft_processed.”
  • 9999 = run very late so our change happens after other tweaks.
  • 1 = pass one argument to our function (the $post array).
function force_all_imports_to_draft_processed( $post ) {
  • We define that function. It receives the imported post data as $post. This is an array with keys like post_title, post_status, post_type, etc.
    if ( is_array( $post ) ) {
  • Safety check. Make sure $post is actually an array before we touch it.
        if ( isset($post['post_type']) && $post['post_type'] === 'attachment' ) {
            return $post;
        }
  • If this item is a media file (post_type is attachment), we leave it alone and hand it back unchanged.
  • Reason: attachments normally use status inherit and messing with that can break featured images/galleries. But, don’t worry, it will keep your post images and featured images as it was as long as you check the box Download Attachment which you will be show before the import starts (while you follow Import plugin on-screen instruction)
        $post['post_status'] = 'draft';
  • For everything else (posts/pages/custom post types), we force the status to Draft so nothing gets published by accident.
    return $post;
}
  • Give the (possibly modified) post data back to WordPress so it can finish saving it.