• I am using the code directly from Facebook’s share button page (https://developers.facebook.com/docs/plugins/share-button). The only change is that I’m using get_permalink() to pull the post’s url. The problem occurs when I click on the share button. A window opens up for a second and then immediately closes.

    //Social share buttons to the blog posts
        function facebookscript() {
        	if (is_single()) {
        	echo '<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 = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.7&appId=[removed]"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\'));</script>';
        }
        }
    
    add_action('fl_body_open','facebookscript');
    
        function posttopsocial() { 
    
          	$postpermalink = get_permalink();
        	$emailshare = '<a class="email-button" href="mailto:?Subject=Triune Article&Body=Interesting%20Article%20from%20Triune!%20'.$postpermalink.'" target="_blank"><i class="fa fa-envelope-o"></i> Email</a>';
    
        	//TEMPORARY REMOVED ->
    
    	if (is_single()) {
    		echo $facebookscript;
    		echo '<div id="posttopsocial"><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="mwdeterding">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
    			<script src="http://connect.facebook.net/en_US/all.js#appId=[removed]&xfbml=1"></script> <fb:like href="http://triuneleadershipservices.com/build-environment-people-aspire-join/" send="false" layout="button_count" width="90" show_faces="false" font="tahoma"></fb:like>
    			<div class="fb-share-button" data-href="'.$permalink.'" data-layout="button_count" data-size="small" data-mobile-iframe="true"><a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u='.$permalink.'%2F&src=sdkpreparse">Share</a></div>
    			<script src="http://platform.linkedin.com/in.js" type="text/javascript"></script> <script type="IN/Share" data-counter="right"></script>'.$emailshare.'</div><br />';
    	}
     }
    add_action('fl_post_top_meta_open','posttopsocial');

    I also noticed from running inspect that the following error is showing up:

    Redirect at origin ‘http://triuneclone.flywheelsites.com&#8217; has been blocked from loading by Cross-Origin Resource Sharing policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://triuneleadershipservices.com&#8217; is therefore not allowed access.

    I ran a search and replace to remove the temp domain but that didn’t solve it. Any suggestions?

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Facebook Share Button Code Not Working’ is closed to new replies.