• I have a php script that runs outside of wordpress.

    All it contains is the following code.

    require_once "../wp-load.php";
    $imagePost = array(
    		'post_title' => 'Here',
    		'post_content' => 'Content added later.',
    		'post_status' => 'publish',
    		'post_author' => 1,
    		'tags_input' => "''",
    		'post_category' => array(1),
    		'post_type' => 'post'
    );
    
    $postID = wp_insert_post($imagePost, true);
    die($postID);

    I use to be able to run that without any issues however it now comes up with a white page and the message “Are you sure you want to do this?”. I am really at a loss as to how I should fix this.

    Any help is much appreciated.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    If you can find where in WP code the message is coming from (it’s not wp_insert_post() itself) you can likely determine the condition causing it and take measures so it no longer happens. Try GREPping the entire WP installation for a portion of the message and see what comes up.

    I’d normally give it a go myself for you, but I can’t currently access my installation for a while, so all I can do is suggest you try it.

Viewing 1 replies (of 1 total)
  • The topic ‘Permissions error when using wp_insert_post externally’ is closed to new replies.