- This topic has 8 replies, 4 voices, and was last updated 6 years ago by Agus Sriyana.
-
AuthorPosts
-
January 3, 2018 at 12:23 pm #462562January 3, 2018 at 3:00 pm #462659LeoStaffCustomer Support
Hi there,
What’s the code you are trying to insert and where did they say to insert it?
January 3, 2018 at 6:15 pm #462725SatoriThis is the code provided by facebook:
<div class=”fb-comments”
data-href=”https://developers.facebook.com/docs/plugins/comments#configurator”
data-width=”500″ data-numposts=”5″>Basically they say I should insert it wherever I want the comments plugin to show in. I want to insert it in the single.php file. As I said, I’m using a child theme. It’s just unclear to me what part of the code in the single.php should I override.
January 3, 2018 at 11:20 pm #462813TomLead DeveloperLead DeveloperInserting it via hook vs single.php should make zero difference.
Have you added that code in the single.php to test? You should just have to add the HTML anywhere in the single.php file.
January 4, 2018 at 1:25 pm #463320SatoriWell, basically all of my posts are sharing the same comments. If I make a comment on post 1 it does appear on post 2. And inserting the html on the single.php doesn’t work. I have tried the hook again and it loads the module. Any suggestion on how to resolve this? It’s kinda bizarre.
Should I make a copy of the comments.php to the child theme and then erase everything and paste the facebook’s html? As I understand that is the template for the comments section.
January 4, 2018 at 11:09 pm #463536TomLead DeveloperLead DeveloperHave you considered trying a plugin?:
https://en-ca.wordpress.org/plugins/comments-from-facebook/
https://en-ca.wordpress.org/plugins/facebook-comments-plugin/January 4, 2018 at 11:52 pm #463547SatoriHi Tom. I just got it to work. The first code I was sharing had the wrong url. I mean, I was always using the main url of my site, that’s why all pages were sharing comments, because the comments got assigned to that url. So the trick here is to insert some php calling the actual permalink.
So this is the first code:
<div class="fb-comments" data-href="https://developers.facebook.com/docs/plugins/comments#configurator" data-numposts="5"></div>
And here is how is supposed to be in order to just work:
<div class="fb-comments" data-href="<?php the_permalink(); ?>" data-width="100%" data-numposts="5" data-mobile="Auto-detect" data-colorscheme="light" data-order-by="time"></div>
The secret is “<?php the_permalink(); ?>”. But one thing I noticed is that the code can’t be inserted anywhere in the single.php file as you noted. It’s only on the after main content area where it works. If I try to put it below the comments_template it doesn’t load.
Anyway, thank you for the suggestion on plugins. I’m trying to understand how to do certain things without using a plugin. I’m happy I understand this a little bit more.
January 5, 2018 at 9:54 am #463948TomLead DeveloperLead DeveloperAhh yes, that makes sense.
You should be able to place it in the “After Content” hook in GP Hooks, inside a conditional:
<?php if ( is_single() ) : ?> Your code in here <?php endif; ?>
March 8, 2018 at 3:59 pm #515155Agus Sriyana🙂
` -
AuthorPosts
- You must be logged in to reply to this topic.