Snippets: Add Facebook “Like” Button to Singular Posts

// Add facebook like button block the Customizer so we can enable/disable it and move it around
add_filter( 'wpex_blog_single_blocks', function( $blocks ) {
    $blocks['facebook_like'] = __( 'Facebook Like Button', 'total' );
    return $blocks;
} );

// Front-End output for the button
function my_facebook_like_button_block( $blocks ) {
	if ( isset( $blocks['facebook_like'] ) ) {
		$blocks['facebook_like'] = function() { ?>
			<!-- Load Facebook SDK for JavaScript -->
			  <div id="fb-root"></div>
				<script>(function(d, s, id) {
				    var js, fjs = d.getElementsByTagName(s)[0];
				    if (d.getElementById(id)) return;
				    js = d.createElement(s); js.id = id;
				    js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.0";
				    fjs.parentNode.insertBefore(js, fjs);
				  }(document, 'script', 'facebook-jssdk'));</script>
			<!-- Your like button code -->
			<div class="fb-like"
			data-href="<?php the_permalink(); ?>"
			data-layout="standard"
			data-action="like"
			data-show-faces="true">
			</div>
		<?php };
	}
	return $blocks;
}
add_filter( 'wpex_blog_single_layout_blocks', 'my_facebook_like_button_block' );
All PHP snippets should be added via a child theme's functions.php file.