Button 链接至;别针;在pinterest上不生成按钮

Button 链接至;别针;在pinterest上不生成按钮,button,pinterest,Button,Pinterest,我有一个页面,上面有几十到几百篇文章,每一篇都有社交按钮。 我只是不能为每个url生成所有按钮:它太慢了(facebook、g+、twitter、pinterest……有数百个链接)。因此,我使用一个简单的img指向 https://www.facebook.com/sharer.php?u=${url_of_current_post}&t= 当用户点击它时,会打开一个弹出窗口,显示facebook生成的内容 我怎样才能为Pinterest做到这一点?我只找到了生成按钮的代码,但如果可

我有一个页面,上面有几十到几百篇文章,每一篇都有社交按钮。 我只是不能为每个url生成所有按钮:它太慢了(facebook、g+、twitter、pinterest……有数百个链接)。因此,我使用一个简单的img指向

https://www.facebook.com/sharer.php?u=${url_of_current_post}&t=
当用户点击它时,会打开一个弹出窗口,显示facebook生成的内容

我怎样才能为Pinterest做到这一点?我只找到了生成按钮的代码,但如果可能的话,我想避免使用js。有类似于下面的东西吗

http://pinterest.com/pinthis?url=${url_of_current_post}

请不要试图让我使用js按钮,谢谢。

标准Pinterest按钮代码(您可以)是一个


如果使用JavaScript版本的共享按钮破坏了页面加载时间,可以使用异步加载方法改进站点。有关使用Pinterest按钮执行此操作的示例,请查看我的。

我找到了wordpress的一些代码:

<a href="http://pinterest.com/pin/create/button/?url={URI-encoded URL of the page to pin}&media={URI-encoded URL of the image to pin}&description={optional URI-encoded description}" class="pin-it-button" count-layout="horizontal">
    <img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" />
</a>

函数插入\u pinterest($content){
全球$员额;
$postrl=urlencode(get_permalink());//获取帖子URL
$pinspan='';
$pinurl='';
$pinend='';
$pattern='//i';
$replacement=$pinspan.$pinurl.'$2.$3.$pindescription.$pinfinish.'.$pinnd;
$content=preg_replace($pattern,$replacement,$content);
//修复链接问题
$newpattern='//i';
$replacement='';
$content=preg_replace($newpattern,$replacement,$content);
返回$content;
}
添加过滤器('the'u content','insert'u pinterest');
然后将以下内容放入PHP中:

 <script type="text/javascript">

    function insert_pinterest($content) {
        global $post;
        $posturl = urlencode(get_permalink()); //Get the post URL
        $pinspan = '<span class="pinterest-button">';
     $pinurl = '';
     $pinend = '</span>';
        $pattern = '//i';
        $replacement = $pinspan.$pinurl.'$2.$3'.$pindescription.$pinfinish.''.$pinend;
        $content = preg_replace( $pattern, $replacement, $content );
        //Fix the link problem
        $newpattern = '/<span class="pinterest-button"><\/a><\/span><\/a>/i';
     $replacement = '';
     $content = preg_replace( $newpattern, $replacement, $content );
     return $content;
    }
    add_filter( 'the_content', 'insert_pinterest' );

    </script>

那么您希望代码在不安装按钮的情况下锁定按钮?如果是这样的话,只需将此代码粘贴到要锁定的页面的url位置即可。在没有按钮的情况下,它应该起到固定按钮的作用


javascript:void((function(){var%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*9999999);document.body.appendChild(e)}()

如果要创建一个简单的超链接而不是“锁定”按钮

更改此项:

<?php $pinterestimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>
<a href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink($post->ID)); ?>&media=<?php echo $pinterestimage[0]; ?>&description=<?php the_title(); ?>">Pin It</a>
为此:

http://pinterest.com/pin/create/button/?url=
因此,一个完整的URL可能就是这样:


我也有同样的问题。这在Wordpress中非常有效

http://pinterest.com/pin/create/link/?url=

您可以使用小型jQuery脚本创建自定义链接

<a href="//pinterest.com/pin/create/link/?url=<?php the_permalink();?>&amp;description=<?php the_title();?>">Pin this</a>
这将适用于具有class
linkPinIt
的所有链接,这些链接的图像和描述存储在HTML 5数据属性
data image
data desc

$('.linkPinIt').click(function(){
    var url = $(this).attr('href');
    var media = $(this).attr('data-image');
    var desc = $(this).attr('data-desc');
    window.open("//www.pinterest.com/pin/create/button/"+
    "?url="+url+
    "&media="+media+
    "&description="+desc,"_blank","top=0,right=0,width=750,height=320");
    return false; 
});


查看此

对于这种情况,我发现非常有用,它有助于创建Facebook、Google+、Twitter、Pinterest、LinkedIn共享按钮。

这对我很有用,但有两个问题。如何维护弹出窗口?另外,随机数学是做什么的?这是Pinterest的官方代码,来自他们的“bookmarklet”。它通常用作保存到书签的链接,并可以单击您访问的任何网站以打开Pinterest对话,但这种方式也很好用,并且易于实现。它们非常明确地告诉您不要在API文档中这样做。仅仅因为你可以,并不意味着你应该。回答得很好,谢谢!另外,请参见我们在developer.pinterest.com上的页面,这里:Pin-It widget builder对于获取一些示例代码也很有用,您可以通过编程定制这些示例代码。@KentBrewster-值得一提的是,在访问您的页面后,我在这里提出了同样的问题。它提供的信息都很好,但它没有提到URL参数,也没有提到URL可以在不使用javascript的情况下使用(在动态创建按钮的环境下),就像facebook和twitter的等价页面一样。我在描述中的urlencode有点僵硬。知道为什么吗?示例:“在这一点上,我只是想从另一篇文章中复制和粘贴,因为时间不够。”——显然不太理想。如果用户已经登录pinterest,上面的答案就可以了,否则即使成功登录,它也会停留在pinterest主页上。有什么解决办法吗?我更喜欢自己制作链接。这仍然有效,还是他们已经更改了它?如果您有另一个pinterest按钮(并且加载了pinit.js脚本),则接受的答案将生成一个按钮。将url更改为“link”而不是“button”,将允许您在页脚中使用pinterest按钮,并在页面的某个位置使用自定义pinterest链接。这应该是公认的答案。谢谢你的回答,这正是我想要的。在我看来,这应该是正确的答案:)我对这个答案投了赞成票,但后来发现pinterest在尝试pin时抛出了一个错误:
Parameter'method'(值链接)不是未知、上传、刮取、书签、电子邮件、iphone、按钮、ipad、android、android平板电脑、api\U sdk、扩展、api\U other,糟糕。
。解决方案是将url保持为
按钮
,但忽略pinterest脚本。请参阅目前未引发错误:P使用作为属性列表共享链接:
http://pinterest.com/pin/create/link/?url=URL&media=COVERIMAGE&description=ADDRESS
<a href="https%3A%2F%2Fwww.flickr.com%2Fphotos%2Fkentbrew%2F6851755809%2F" 
   data-image="https%3A%2F%2Fc4.staticflickr.com%2F8%2F7027%2F6851755809_df5b2051c9_b.jpg" 
   data-desc="Title for Pinterest Photo" class="linkPinIt">
    Pin it!
</a>