Custom share button on a wordpress site – doesn’t open a new window correctly

I have been searching the web for ways to make a custom share button for my wordpress site posts.

1 – So I have my own image “share” file.
2 – Pasted this code in the tag:

Read More
<script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : 'myNumber',
          xfbml      : true,
          version    : 'v2.0'
        });
      };

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


      $('.btnShare').click(function(){
        elem = $(this);
        postToFeed(elem.data('title'), elem.data('desc'), elem.prop('href'), elem.data('image'));

        return false;
        });
    </script>

3 – on my single.php page I added this line:

<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&amp;t=<?php the_title(); ?>" title="Share on Facebook." target="_blank">SHARE</a>

The problem is that it opens a normal window and not the regular small pop-up window that facebook usually has.

Can someone help me fix this?
If you have any good tutorials how to add a custom Facebook button without any trouble I’ll be happy to start all over.
(no wordpress plugins pls..)

TNX,
Hatzil666.

Related posts

Leave a Reply

1 comment

  1. Try this:

    <a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>" title="Share on Facebook." onclick="window.open(this.href, 'newwin', 'width=200, height=100'); return false;" >SHARE</a>
    

    Modify the width, height, scrollbars etc within the options