WordPress.org

Ready to get started?Download WordPress

Forums

wp_insert_post fails to add comment_count (3 posts)

  1. Debashish
    Member
    Posted 4 years ago #

    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?

  2. MichaelH
    Member
    Posted 4 years ago #

    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.

  3. Debashish
    Member
    Posted 4 years ago #

    @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.

Topic Closed

This topic has been closed to new replies.

About this Topic