Sign in to follow this  
Followers 0
Mr.XXIV

Redirect To Facebook Like Button's URL When Clicked

1 post in this topic

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="http://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(); ?>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.