after wp_insert_post need to get the post id

I have a function in function.php and it does wp_insert_post.
how can I get the post id which just posted?

when I do wp_insert_posts, it saves a PR value (unique and it saves in post-meta table). Do I need to do “select”?
like select post_id from wp-post where oid=”.$oid…… etc
like this?

Read More

I have tried to get
$post_id = wp_insert_post($new_post);
$post_id = get_post($post_id)
But these are not working.

I am not also very good at wp join. how can I do?

Related posts

1 comment

  1. $post_ID = wp_insert_post($post);
    

    … should work, as you mentioned. From the Codex:

    Returns the ID of the post if the post is successfully added to the database. On failure, it returns 0 if $wp_error is set to false, or a WP_Error object if $wp_error is set to true.

Comments are closed.