Title: Problem publishing a post using wp_update_post()
Last modified: August 30, 2016

---

# Problem publishing a post using wp_update_post()

 *  [alexgagi](https://wordpress.org/support/users/alexgagi/)
 * (@alexgagi)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/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: [Image](http://i0.wp.com/pruebas.cefoto.es/wp-content/uploads/2015/09/ACF.jpg,)
 * Thanks for your help.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/problem-publishing-a-post-using-wp_update_post/#post-6539204)
 * FYI, I’m blocked from seeing your image. No matter, I think I understand what’s
   happening. Have you tried checking the frontend page sometime later without going
   to the backend? It maybe that the server has not finished updating the DB when
   the next request comes through, thus it still appears as empty.
 * Another possibility is saving the score does not update the cache, but editing
   the post does. If the frontend page is loaded from cache, the score will never
   appear until the cache is flushed or updated.
 *  Thread Starter [alexgagi](https://wordpress.org/support/users/alexgagi/)
 * (@alexgagi)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/problem-publishing-a-post-using-wp_update_post/#post-6539225)
 * Dear [@bcworkz](https://wordpress.org/support/users/bcworkz/), thanks for your
   response and sorry about the image link.
    Now I hope you can see it: [Image correct](https://drive.google.com/file/d/0B5ovYol3zbFKVFRVRGRYbk9pYWc/view?usp=sharing).
   About your response, I have not explained well, and without image it is difficult
   to make me understand. It’s not a question of time, because even days after the
   field is still not in there. But the problem is not that the scoring does not
   save, is that the field (the space) to score doesn’t even appear. I think the
   problem is with wp_update_post(), something is missing when I publish the post
   using this function. It makes me mad… Thanks a lot.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/problem-publishing-a-post-using-wp_update_post/#post-6539282)
 * Thank you for making the image accessible, it does explain a lot!
 * I see you are using ACF, which I am not very familiar with. My understanding 
   is you can define fields and forms, then cause them to display by using a shortcode.
   If that is incorrect, my apologies. Based on my marginal understanding, it appears
   the shortcode is not being expanded by ACF code for some reason. There is something
   about how the form is output that bypasses the part of WP that expands shortcodes.
 * Then when it is saved in the backend, that part works. I don’t know enough about
   your site to speculate how this can be happening, but I can tell you that you
   can force shortcode expansion when it is not happening automatically by passing
   the content through `do_shortcode()`. When you output the returned content all
   shortcodes within will be expanded, provided they were properly registered beforehand.
 * Which points to the other possibility: that for some reason ACF cannot register
   its shortcode before the form is processed. Why this would happen I could not
   say, only that it is a possible explanation.
 * I know I have not answered your question, but hopefully this gives you a better
   idea where to search for the actual cause or how to work around it. Good luck!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problem publishing a post using wp_update_post()’ is closed to new replies.

## Tags

 * [publishing](https://wordpress.org/support/topic-tag/publishing/)
 * [wp_update_post](https://wordpress.org/support/topic-tag/wp_update_post/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/problem-publishing-a-post-using-wp_update_post/#post-6539282)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
