Search code examples
javascriptjqueryhtmlpinterest

Pinterest Share HTML Link error


I am having an issue with my 'Share to Pinterest' link. I have a JSFiddle if it helps.

Basically the url portion isn't being carried into my new pop up window :'-(

Here's my Javascript too:

$('.share.pinterest').click(function(e){
        e.preventDefault();

        var target = $(this),
            url = target.data('url') || "";

        var width  = 575,
            height = 400,
            left   = ($(window).width()  - width)  / 2,
            top    = ($(window).height() - height) / 2,
            gplus    = 'https://www.pinterest.com/pin/create/button/?url='+ url + '',
            opts   = 'status=1' +
                     ',width='  + width  +
                     ',height=' + height +
                     ',top='    + top    +
                     ',left='   + left;


        window.open(gplus, 'Pinterest', opts);

    });

Many thanks for any help & guidance with this issue.


Solution

  • <a href="http://www.pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php if(function_exists('the_post_thumbnail')) echo wp_get_attachment_url(get_post_thumbnail_id()); ?>&description=<?php echo get_the_title(); ?> - <?php echo get_permalink(); ?>" id="pinterest" target="_blank">Pinterest Pin It</a>