Problem publishing a post using wp_update_post()
-
Hello, I’m developing a plugin to convert a web in a photo contest website and I’m facing a problem I can’t figure out the solution. What I do:
1. I have a front end form for the user to submit a CPT with a title and image. The CPT remains as a draft until someone takes a look on it.
2. On an options page I use a function to publish the posts and assign to them a custom taxonomy:$idpost = get_the_id(); $my_post = array( 'ID' => $idpost, 'post_status' => 'publish' ); wp_set_object_terms($idpost, 'votacion', 'temas_liga', false); wp_update_post( $my_post );
3. I then have a single taxonomy template to show them. In that single page I have a form for the scoring of the image.
Everything works almost perfect: the images go to draft, then go to published and got the term, and I can see it on the single tax page.
But the field with the score is not showing. I can see the submit button, the form is created, even the div for the field, but it is empty when you see the html.
More funny is that if I go in the backend to edit the CPT and I just save the CPT without making any change, then I go to the frontend single page and then the scoring field appears.
I have an image to explain better, the image on the left has been saved on the backend and the image on the right has not been saved on the backend: ImageThanks for your help.
- The topic ‘Problem publishing a post using wp_update_post()’ is closed to new replies.