Support » Plugins » Problem Update The Post!

  • Hi, I need to append some data to post A after creating post B. The following is my code and for some strange reasons, it’s stuck at wp_get_single_post. I followed the codex example quite closely, but I still couldn’t figure how why it’s stuck there.
    The only culprit I can think about is because I’m not running this from the loop, but I didn’t think it mattered because I’m retrieving and updating a single post. Any inputs are greatly appreciated.

    function some_func() {
    	$new_post = array (
    			//some data here
    	$directory_pid = wp_insert_post($new_post, $wp_error);
    	if ($directory_pid == 0) {
    		$output .= "error, can't create post.";
    	} else {
    		$content = 'some data to append';
    		$output .= update_entry($current_pid, $content);
    function update_entry($current_pid, $content) {
    	$current_post = wp_get_single_post($current_pid);
    	if ($current_post) {
    		$updated_content = array(
    			'id' => $current_pid,
    			'post_content' => $current_post->post_content . $content
    		if (wp_update_post($updated_content) == 0 ) { return $output = "wp_update_post is wrong"; }
    		return true;
    	} else {
    		return $output = "wp_get_single_post is wrong";
  • The topic ‘Problem Update The Post!’ is closed to new replies.