WordPress.org

Ready to get started?Download WordPress

Forums

Facebook Comments to WordPress
Fix to get correct comment count (4 posts)

  1. rweibull
    Member
    Posted 1 year ago #

    Hi,

    I found that the comments importer works in WordPress 3.5, however the comment count for every post did not get updated.

    To fix this, simply change this in FacebookCommentImporter.php on line 220 onwards from:

    if ($db->insert($db->prefix.'comments', $data)) {
                    $this->commentMap[$comment['id']]['id'] = $db->insert_id;
                } else {
                    return;
                }

    to:

    if ($wpcid = wp_insert_comment($data)) {
                    $this->commentMap[$comment['id']]['id'] = $wpcid;
                } else {
                    return;
                }

    That uses the WordPress function to insert the comment instead of writing directly to the database. This also updates the comment_count in the wp_posts table.

    http://wordpress.org/extend/plugins/facebook-import-comments/

  2. Vidulous
    Member
    Posted 1 year ago #

    thanks for the good info share! +1

  3. tozo
    Member
    Posted 1 year ago #

    @rweibull, thanks for sharing! Did you modify anything else besides line 220? I can not determine if it works for my WordPress 3.5. I don't see any errors and applied your fix as well as (to prevent comment deletion):

    line 39
    if (is_array($locComments) && is_array($locComments['data']))

    TO:
    if (is_array($locComments) && is_array($locComments['comments']['data']))

    and line 43
    $helper->import($comments['data'], $this->importMode);

    TO:
    $helper->import($comments['comments']['data'], $this->importMode);

    http://wordpress.org/support/topic/plugin-facebook-comments-to-wordpress-warning-invalid-argument-supplied-for-foreach-in-homesafezonedudelolcomw

  4. steelmaiden
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.