Forums

Getting id of user-submited posts (2 posts)

  1. shogun82
    Member
    Posted 2 years 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
    Volunteer
    Posted 2 years ago #

    $your_post_id=wp_insert_post( $my_post );

Topic Closed

This topic has been closed to new replies.

About this Topic