I'm using wp_insert_post function to insert a new post:

$result = wp_insert_post(array("post_title"=>"test1"), true);

When I echo the result of the function, I get the number 335. How can I see what is the meaning of this code. I tried this with no success:

$error = new WP_Error($result);
echo ($error->get_error_message($result));
  • 5
    var_dump($result); or you can use if( is_wp_error($result) ) echo $result->get_error_message(); (not tested) :) Dec 30, 2015 at 6:19

1 Answer 1


335 is not an error message or code, it is the new post's ID that is retuned, so in short, the new post you have inserted was given the ID of 335


wp_insert_post() already returns a WP_Error object on failure, so simply var_dump( $result ); would give you a specific error message on failure or the new post ID on success

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.