So I’m running WordPress on localhost, with a Facebook comments plugin installed. I turned on platform apps on Facebook, created an app, clicked “Settings,” clicked “Add Platform,” selected “Website,” and typed “localhost” into the Site URL and App Domains fields. Then in WordPress I pasted the App ID and App Secret into the Facebook plugin settings.
The Facebook comments box then shows up on my local blog… with 11 comments from people in various countries. Most of them typed “test” or something similar, so I imagine they’re testing their own systems. I don’t know why their systems got linked to mine, though.
But when I try to submit a Facebook comment myself, there’s a small progress bar animation and then nothing gets posted.
I’ve looked through other StackOverflow answers, mainly this one, and tried changing the Site URL and App Domains fields to localhost:3000, localhost:8000, and localtest.me. (Changing the site URL to 127.0.0.1 gives an error message which says that address “is invalid because it is a Facebook url”.) Also, I checked my hosts file to confirm that “localhost” points to 127.0.0.1.
Nothing’s worked so far. Any ideas?
P.S. I can still post Facebook comments on other websites. Just not the blog on my local machine.
EDIT:
In response to David’s request for more information… It seems the problem starts earlier than I thought. When I first click “Add a comment” to open the Facebook comment box, the Firefox console gives an error:
Empty string passed to getElementById().
Despite this error message, on the blog page itself everything looks fine. The Facebook comments box opens up as it should… Then I type in a comment and click “Comment,” and get a 2nd console error:
Use of getAttributeNode() is deprecated. Use getAttribute() instead.
And the Facebook comment does not get submitted or posted. The comment box just (briefly) displays a mini-progress bar.
EDIT 2:
Now that Facebook comments are working correctly, I see that those two error messages are still appearing. Presumably this means they aren’t actually related to my previous inability to post comments.
JS version of share. To try just put in your page. If it works, enqueue it.
html
Then try your localhost settings in the app details. I always have problems with FB on localhost, they seem to change how they deal with it consistantly but try your different ports and you should get it!
I decided to use a workaround:
(1) Creating a WordPress blog on a remote host, (2) installing and configuring Facebook comments, (3) copying the blog to my local machine with the Duplicator plugin, (4) creating a new blog on the remote host, and (5) installing the WP Clone plugin on both the new remote blog and the local blog.
Finally, I used WP Clone locally to create a .zip file, moved the file into my remote wordpress folder using FTP, and then restored the remote version from that file, as described in the WP Clone FAQ. I’ve been deploying updates the same way (not the most efficient workflow, so I might switch to using Git for updates, but for now it works well).
To make the blog work on localhost, I needed to modify the MySQL settings in wp-config.php (database name, username, password, etc.) to log in to the local database.
Additionally, trying to add new themes or plugins to the local version by clicking “Install Now” gave me a mysterious screen asking for my FTP credentials, until I changed the owner of the wordpress folder and files to _www. I also made sure that the folder permissions and file permissions were set respectively to 775 (from 755) and 664 (from 644).
So now WordPress is up and running, both on localhost and on my remote host, and I can post my Facebook comments on both versions. I am still getting strangers’ comments on the local blog, though! 😉 No worries, I’m satisfied as long as I can develop locally and know that it works online.