• 0

Redirect To Facebook Like Button's URL When Clicked


Question

On this site http://sexesbattle.com

Currently I have code that refreshes the page when one of the like buttons are clicked.

How do I have it redirect to url of the button that's liked as one of them contain a permalink. This is WordPress and the Frontpage has both sides querying randomly til I can figure out how to have one liked image selected to challenge another.


<div id="fb-root"></div>
<script src="https://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId :'00000000000',
		status : true, // check login status
		cookie : true, // enable cookies to allow the server to access the session
		xfbml : true, // parse XFBML
		channelUrl : 'http://WWW.SEXESBATTLE.COM/channel.html', // channel.html file
		oauth : true // enable OAuth 2.0
});
</script>

<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/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<script>
	FB.Event.subscribe('edge.create', function(href, widget) {
		top.window.location = 'http://sexesbattle.com';
	});
</script>


<?php get_header(); ?>

<div id="content">
<div id="or"></div>
	<?php $the_query=new WP_Query(array ( 'orderby' => 'rand', 'posts_per_page' => '1' ));while($the_query->have_posts()):$the_query->the_post(); ?>
		<div id="left" style="background: url(<?php $image_id = get_post_thumbnail_id();$image_url = wp_get_attachment_image_src($image_id,'big', true);echo $image_url[0]; ?>) top center;background-size:cover;">
			<div class="social">
				<fb:like href="<?php echo get_permalink( $the_query->post->ID ); ?>" send="false" layout="button_count" width="71" show_faces="false"></fb:like>
			</div><!-- .social -->
		</div><!-- #left -->
	<?php endwhile;wp_reset_query();wp_reset_postdata(); ?>
	<?php $querytwo=new WP_Query(array ( 'orderby' => 'rand', 'posts_per_page' => '1' ));while($querytwo->have_posts()):$querytwo->next_post(); ?>
		<div id="right" style="background: url(<?php $image_idtwo = get_post_thumbnail_id($querytwo->post->ID);$image_urltwo = wp_get_attachment_image_src($image_idtwo,'big', true);echo $image_urltwo[0]; ?>) center;background-size:cover;">
			<div class="social">
				<fb:like href="<?php echo get_permalink( $querytwo->post->ID ); ?>" send="false" layout="button_count" width="71" show_faces="false"></fb:like>
			</div><!-- .social -->
		</div><!-- #right -->
	<?php endwhile;wp_reset_query();wp_reset_postdata();?>
</div><!-- #content -->

<?php get_footer(); ?>

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.