levani01
Member
Posted 2 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
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'.
levani01
Member
Posted 2 years ago #
Oh, thank you very much, I new that everything would be much easyer. :)