Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HEADER:
- <script>
- window.fbAsyncInit = function(){
- FB.init({
- appId: 'mojAppID', status: true, cookie: true, xfbml: true });
- };
- (function(d, debug){var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
- if(d.getElementById(id)) {return;}
- js = d.createElement('script'); js.id = id;
- js.async = true;js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
- ref.parentNode.insertBefore(js, ref);}(document, /*debug*/ false));
- function postToFeed(title, desc, url, image){
- var obj = {method: 'feed',link: url, picture: 'http://www.url.com/images/'+image,name: title,description: desc};
- function callback(response){}
- FB.ui(obj, callback);
- }
- </script>
- INDEX.PHP
- Loop početak-->
- <?php
- $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' );
- $url = $thumb['0'];
- ?>
- <a href="<?php the_permalink('');?>" data-image="<?php the_post_thumbnail(''); ?>" data-title="<?php the_title();?>" data-desc="<?php the_excerpt();?>" class="btnShare">Share</a>
- FOOTER:
- <script>
- $('.btnShare').click(function(){
- elem = $(this);
- postToFeed(elem.data('title'), elem.data('desc'), elem.prop('href'), elem.data('image'));
- return false;
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement