• Resolved adammmmm

    (@adammmmm)


    I tried to create a form for posting outside the admin panel with some pre-defined fields for users to input. Once the user inputted, inputs post to a processform so that I can manipulate the post_content, add post meta and etc…

    My problem is, in order to insert the custom metas, insert the img uploaded to the post, i have to first get the post ID by wp_insert_post, and then using wp_get_img_src and add_post_meta to manipulate the content and then update the post content by using the wp_insert_post again. I found out that img does work but the post_meta will be brought forward to the revised post.

    Anyone can help/suggest a way that what I could do?

    Thanks,
    Adam

Viewing 5 replies - 1 through 5 (of 5 total)
  • https://vudu.me/5u

    Not sure if this will be any help for you. I have a series of posts on posting through a form from the frnt end. Including images and post meta

    Thread Starter adammmmm

    (@adammmmm)

    thx voodoo.
    my input form no. of items (& files) was variable so it’s quite difficult for me to manipulate the content without a post_id (or i have to manage a chunky code like using variable variables which is not preferred)

    let me simplified my question a bit:
    how could post_meta be brought along to the revised version of a post?

    well why don’t you have it inserted as a draft, then revise it however you do and set it to published?

    otherwise, you would have to save post_meta in a new table in the database, that then gets read when you go to revise it.

    Thread Starter adammmmm

    (@adammmmm)

    thx digibucc,
    i tried this approach as well, i used the wp_insert_post to create draft,
    do what i want and then user wp_insert_post (ID->post_id) to revise content and make it publish…but post_id altered….meta inserted into original post_id didn’t show on revised post, that’s the problem i faced.

    Thread Starter adammmmm

    (@adammmmm)

    thanks everyone, would like to share the approach that i handle the post_meta wasn’t brought to the new post_id issue.
    I finally using the variable variables (php) and iterate again after getting getting new_post_id (2nd insert). It’s not nice and a bit chunky though….

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘post_id keeps changing’ is closed to new replies.