2014-01-06 31 views
1

我想添加一个pinterest链接到我的WordPress的网站。这里的计算器,我发现下面的代码:在WordPress的Pinterest链接给出错误

<?php 
    /*Stuff for Pinterest*/ 
    //getting the permalink 
    $postpermalink = urlencode(get_permalink()); 
    //getting the thumbnail 
    $imageurl = urlencode(wp_get_attachment_url(get_post_thumbnail_id($post->ID))); 
    /*End of Pinterest*/ 
?> 
<a target="blank" href="http://pinterest.com/pin/create/button/?url=<?php echo $postpermalink ?>&media=<?php echo $imageurl ?>" title="Pin This Post">pinterest</a> 

但是当我测试了一下,Pinterest的给了我以下错误:

Whoops! Parameter 'method' (value link) is not one of unknown, uploaded, scraped, bookmarklet, email, iphone, button, ipad, android, android_tablet, api_sdk, extension, api_other, bad.

我已经试过吨等不同环节,但没有成功。有任何想法吗?

回答

0

试试这个

/*Stuff for Pinterest*/ 
//getting the permalink 
$postpermalink = urlencode(get_permalink()); 
//getting the thumbnail 
$imageurl = urlencode(wp_get_attachment_url(get_post_thumbnail_id($post->ID))); 
/*End of Pinterest*/ 

echo '<a target="blank" href="http://pinterest.com/pin/create/button/?url=' . $postpermalink . '&amp;media=' . $imageurl . '" title="Pin This Post">pinterest</a>'; 
+0

感谢您的帮助,但不幸的是,这也不起作用。 – Jando

+0

更正了上述代码中的拼写错误,它在我的安装中工作正常。 – user3167160

1

根据在Pinterest的这个资源,你需要包含JavaScript链接在页面的某个地方或否则针它链接将无法正常工作(我跑进pinit.js今天这个非常相同的问题):

https://developers.pinterest.com/pin_it/

这样做的缺点这种方式是,如果你有你的链接内的任何自定义的图形或文字,那些被覆盖b Ÿjavascript代码,并且我无法找到一种方法来覆盖此时的行为。我正在为这个页面添加书签,希望有人发现或将找到某种魔术方式来覆盖pinterest覆盖。

相关问题