Facebook comments for pages with dynamic URL

by Goran Siric on Sunday, April 09, 2017 6:53 AM

The comments plugin lets people comment on content on your site using their Facebook account. People can choose to share their comment activity with their friends (and friends of their friends) on Facebook as well. The comments plugin also includes built-in moderation tools and social relevance ranking.

Here are steps that I have taken for adding Facebook comments on my blog page with dynamic URL.

  • Create new application on Facebook apps page

  • Go to Facebook comment plugin page and get code for your comments plugin. You will get JavaScript and HMTL code you need to include in your page.  

  • Make sure you have JQuery support on your pages

  • Include this script on your page:

    <script>
        $(document).ready( function() { $(".fb-comments").attr("data-href", window.location.href.split('?')[0]); });
    </script>

 

Note that if you look at page source, it will still contain original URL you entered while creating comment plugin. Don't worry about that, comments will be displayed based on dynamic URL of the page.


Cartoon source: Geek And Poke Cartoons

 

Author
Goran Siric

Blog about programming



  Hi folks! I am proud to present: 
Bubble Zoo Escape, my first Android game built using AndEngine 
If you have a time, please download and give feedback!

If you found this useful,
you can buy me a coffe :)

By me a coffe through PayPal :)


Featured articles

AndEngine - Textures tips and tricks

What you should know abot textures before get started programming your first game.

GIMP script for creating Android icons at once

Script for creating Android icons for different screen resolutions at once. Icons can be saved using standard Android icons naming conventions and saved in appropriate folders.

Creating Android button with image and text using relative layout

Source code with examples how to use relative layout to create nice buttons with text and images in Android

Android application and the Internet

Tutorial about connecting to the web pages on the Internet from Android application, using both POST and GET web requests.

Copyright 2011 by Goran Siric