Forums

Getting id of user-submited posts (2 posts)

  1. shogun82
    Member
    Posted 3 weeks ago #

    Hello.

    Im using this to create new post:

    $my_post = array();
    $my_post['post_title'] = 'Ankieta wypełniona przez: ' . $a11;
    $my_post['post_content'] = $info;
    $my_post['post_status'] = 'publish';
    $my_post['post_author'] = 1;
    $my_post['post_category'] = array(1);

    wp_insert_post( $my_post );

    how can i get the id of that new post? i need this id to be saved in a separate sql table.

    this is for people who are filling my form with some questions. i need to send them link to their posts via email.

    thx :)

  2. MichaelH
    moderator
    Posted 3 weeks ago #

    $your_post_id=wp_insert_post( $my_post );

Reply

You must log in to post.

About this Topic