WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Add some meta data to post inserted using wp_insert_post function (3 posts)

  1. levani01
    Member
    Posted 4 years ago #

    I'm using wp_insert_post function to insert new post but I need to add some meta data to each post as soon as it's inserted. How can I do that? Should I retrieve the most recent post id ofter the post is inserted and use the id or there is some simpler method?

    Thanks

  2. s_ha_dum
    Member
    Posted 4 years ago #

    Should I retrieve the most recent post id ofter the post is inserted and use the id or there is some simpler method?

    That's what I'd do, except that wp_insert post will return the "ID of the post if the post is successfully added to the database" so you don't have to retrieve the ID. You already have it. Just catch the ID like so $myinsertedpostID = wp_insert_post($whatever); and check that it isn't '0'.

  3. levani01
    Member
    Posted 4 years ago #

    Oh, thank you very much, I new that everything would be much easyer. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.