WordPress.org

Support

Support » How-To and Troubleshooting » wp_insert_post fails to add comment_count

wp_insert_post fails to add comment_count

  • I am running the following piece of code (assume all variables have values) is a custom importer that I am trying for Joomla2Wordpress.

    $ret_id = wp_insert_post(array(
    		'ID'			=> $pinfo,
    		'post_date'		=> $Posted,
    		'post_date_gmt'		=> $post_date_gmt,
    		'post_author'		=> $authorid,
    		'post_modified'		=> $LastMod,
    		'post_modified_gmt' => $post_modified_gmt,
    		'post_title'		=> $Title,
    		'post_content'		=> $Body,
    		'post_excerpt'		=> $Excerpt,
    		'post_status'		=> $post_status,
    		'post_name'		=> $sefurl,
    		'comment_count'		=> $comments_count)
    	);

    However while the code inserts post correctly, the comments count is not updated (remains zero). The codex page doesn’t mention the parameter at all.

    Can anybody help?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Just a guess you will need to look at the function wp_insert_comment in the wp-includes/comment.php file to do what you want.

    @michael You are right but I was rather inclined to know whether there is any bug related to the function or am I doing something wrong.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_insert_post fails to add comment_count’ is closed to new replies.
Skip to toolbar