我正在嘗試在每個帖子上使用針對Pinterest的自定義「Pin It」按鈕,該按鈕從該帖子的精選圖像中拉出。使用自定義Pinterest「Pin It」按鈕顯示發佈的特徵圖像?
到目前爲止,我有這個腳本,成功拉後的特徵圖像,以及它顯示在一個彈出窗口:
<script type="text/javascript">
(function() {
window.PinIt = window.PinIt || { loaded:false };
if (window.PinIt.loaded) return;
window.PinIt.loaded = true;
function async_load(){
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
s.src = "http://assets.pinterest.com/js/pinit.js";
var x = document.getElementsByTagName("script")[0];
x.parentNode.insertBefore(s, x);
}
if (window.attachEvent)
window.attachEvent("onload", async_load);
else
window.addEventListener("load", async_load, false);
})();
</script>
這裏是我在單次使用的代碼。 php:
<?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>
我不知道如何將「Pin It」按鈕更改爲我自己的自定義按鈕;每次我嘗試我的按鈕被覆蓋。
我希望這解釋得很好。我對php和javascript仍然很陌生。感謝您提供任何幫助。