How to use Facebook Comments plugin dynamically in your PHP websites



This tutorial in this video showing you how to use Facebook Comments Plugin dynamically on each page of your website without adjusting it one by one on each page with the help of PHP.

Here is the code:

<!DOCTYPE html>
<html>
	<head>
		<title>Dynamic Facebook Comments Plugin Tutorial</title>
	</head>
	<body>
	
		<?php
		
			$weblink = "http://localhost/phptutorials/facebookcommentsplugin/";
		
			if(isset($_GET["about"])){
				
				$weblink = $weblink . "?about";
				
				?>
				
				<h1>About</h1>
				<p>This is About page</p>
				
				<?php
			}else if (isset($_GET["contactus"])){
				
				$weblink = $weblink . "?contactus";
				
				?>
				<h1>Contact us</h1>
				<p>Your contents here</p>
				<?php
			}else{
				
				?>
				
				<h1>Dynamic Facebook Comments Plugin Tutorial</h1>
				<p>Your contents here</p>
				
				
				
				<?php
				
			}
		
		?>
		
		<div id="fb-root"></div>
		<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v5.0&appId=569420283509636&autoLogAppEvents=1"></script>
		
		<div class="fb-comments" data-href="<?php echo $weblink ?>" data-width="" data-numposts="5"></div>
		
	</body>
</html>
loading...

Leave a Reply

Your email address will not be published. Required fields are marked *