WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] how to add post_meta data to a newly created post – by csv import?

[Resolved] how to add post_meta data to a newly created post – by csv import?

Viewing 2 replies - 1 through 2 (of 2 total)
  • a quick addition: a simple method of asking the question, perhaps.

    how to get wp_insert_post( $my_post ); to return my ID for the new post.
    So far as I can see, it only returns a true or false.
    what I’d need is something like
    wp_insert_post( $my_post ) => ID result?

    can you say Duh?

    problem solved.
    get the id easily by
    $newpost=wp_insert_post( $my_post );

    $newpost returns ID number, as per info found on wordpress docs.

    coulda sworn I read up before…. but must have missed this simple line.
    as per the docs:
    “This function inserts posts (and pages) in the database. It sanitizes variables, does some checks, fills in missing variables like date/time, etc. It takes an object as its argument and returns the post ID of the created post (or 0 if there is an error).”
    http://codex.wordpress.org/Function_Reference/wp_insert_post

    Thought I’d make it handy for any others who got puzzled.

    well that solves it, a nice csv import with a few lines of php and we’re on our way to building a custom storefront/blog website for our biz.

    pretty cool.
    thanks for listening.
    vince.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] how to add post_meta data to a newly created post – by csv import?’ is closed to new replies.