tumblr_如何在WordPress中添加Tumblr共享按钮

tumblr

Just like Facebook’s Like Button, Send Button, Twitter’s Retweet Button, LinkedIn’s Share Button, Tumblr, a micro-blogging service, has launched their very own share button. The whole point of this button is to make it effortless for more than 16 million Tumblr bloggers to promote your content on their blogs. This share widget lets Tumblr users easily “Reblog” the content found all over the web rather than just on Tumblr. This reblog option is one of the key features behind the huge social aspect of Tumblr. In this article, we will show you how to add the Tumblr Share Button in WordPress.

就像Facebook的Like ButtonSend ButtonTwitter的Retweet ButtonLinkedIn的Share Button ,微博客服务Tumblr一样,他们也推出了自己的共享按钮。 此按钮的全部目的是使超过1600万的Tumblr博客轻松地在其博客上推广您的内容。 通过此共享小部件,Tumblr用户可以轻松地“重新博客”在整个Web上找到的内容,而不仅仅是在Tumblr上。 此重博客选项是Tumblr巨大的社会方面背后的关键功能之一。 在本文中,我们将向您展示如何在WordPress中添加Tumblr共享按钮。

Previously, when we wrote about WordPress Post Formats that added micro-blogging functionalities into WordPress, we further elaborated on how this can actually allow WordPress to replace Tumblr for those users who want more control. We were bashed by email from various users saying “WordPress doesn’t let you have the social aspect that Tumblr does because it has a community of bloggers re-blogging your thing”. Well, now you can have that feature in your WordPress posts.

以前,当我们撰写有关WordPress帖子格式的文章时,在WordPress中添加了微博客功能,我们进一步阐述了它如何真正允许WordPress为需要更多控制的用户替换Tumblr。 众多用户发来的电子邮件让我们感到沮丧,他说:“ WordPress不允许您拥有Tumblr的社交功能,因为它有一个博客社区来重新博客您的东西”。 好了,现在您可以在WordPress帖子中拥有该功能。

Tumblr Share Button in WordPress

First open up your footer.php file, and paste this code right above the </body> tag:

首先打开footer.php文件,并将此代码粘贴到</ body>标记上方:

<script type="text/javascript" src="http://platform.tumblr.com/v1/share.js"></script>

If you are using a framework, and you do not have access to the footer.php file, then add this code in your functions.php file or custom functions area:

如果您使用的是框架,并且您无权访问footer.php文件,则在您的functions.php文件或自定义函数区域中添加以下代码:

function insert_tumblr_script() {
echo '<script type="text/javascript" src="http://platform.tumblr.com/v1/share.js"></script>';
}
add_action('wp_footer', 'insert_tumblr_script');

Once you have done that, lets take a look at how you can add the code inside your posts:

完成之后,让我们看看如何在您的帖子中添加代码:

基本版本 (Basic Version)

To add the very basic version of the script which will suffice for most users, all you have to do is paste this code where you want in your loop which can be found in (single.php, index.php, page.php, loop.php etc):

要添加满足大多数用户需求的最基本的脚本版本,您所要做的就是将此代码粘贴到循环中所需的位置,该代码可以在(single.php,index.php,page.php,loop .php等):

<a href="http://www.tumblr.com/share" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('http://platform.tumblr.com/v1/share_1.png') top left no-repeat transparent;">Share on Tumblr</a>

You can have various versions of the share image which can be found on the official Tumblr Button page. You can basically select the image you want, and then paste the code from the basics. Alternatively, you can also put your own image for the share by replacing the background: css in the code above.

您可以拥有各种版本的共享图像,这些图像可以在Tumblr Button官方页面上找到 。 您基本上可以选择所需的图像,然后从基础知识中粘贴代码。 另外,您也可以通过替换背景来放置您自己的共享图像:上面代码中的css。

高级定制 (Advanced Customization)

Now as you know with the use of WordPress Post Formats, we are now seeing releases of Micro-Blogging Themes for WordPress. Well, in the basic version for Tumblr button that we discussed above, it pulls the content dynamically. This may cause errors like wrong title appearing, wrong description etc. Also in the basic version, it doesn’t pick the format (link, text, image, quote, video etc) for the Tumblr blogger unlike the Re-Blog function that is used in the Tumblr community.

如您所知,通过使用WordPress帖子格式 ,我们现在可以看到WordPress微博客主题的发布。 好吧,在我们上面讨论的Tumblr按钮的基本版本中,它动态地提取内容。 这可能会导致错误,例如出现错误的标题,错误的描述等。同样在基本版本中,它不选择Tumblr博客的格式(链接,文本,图像,报价,视频等),这与Re-Blog功能不同,即在Tumblr社区中使用。

So the Tumblr share button made sure to built-in advanced functionalities that lets you specify the format of your post by default, specify the pre-filled description, a specific pull quote (complete with attribution) and even specific paragraphs from an article page. So here is an example of how you will add in your loop.php file utilizing the post formats in WordPress:

因此,Tumblr共享按钮可确保内置高级功能,该功能可让您默认指定帖子的格式,指定预填充的说明,特定的拉引号(带有署名)以及文章页面中的特定段落。 因此,这是一个示例,说明如何利用WordPress中的帖子格式添加loop.php文件:


if ( has_post_format( 'link' ) {
?>
<a href="http://www.tumblr.com/share/link?url=<?php echo urlencode(get_permalink()) ?>&name=<?php echo urlencode(get_the_title()) ?>&description=<?php echo urlencode(the_excerpt()) ?>" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('http://platform.tumblr.com/v1/share_1.png') top left no-repeat transparent;">Share on Tumblr</a>
<?php 
} else if (has_post_format('quote')) { ?>
<a href="http://www.tumblr.com/share/quote?quote=<?php echo urlencode(get_the_content()) ?>&source=<?php echo urlencode(get_the_title()) ?>" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('http://platform.tumblr.com/v1/share_1.png') top left no-repeat transparent;">Share on Tumblr</a>
<?php 
}else {
<a href="http://www.tumblr.com/share" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('http://platform.tumblr.com/v1/share_1.png') top left no-repeat transparent;">Share on Tumblr</a>
}

To read more about Customizations refer to the Official Tumblr Button Page.

要了解有关自定义的更多信息,请参阅Tumblr官方按钮页面

Will you be adding this button in your WordPress site?

您要在WordPress网站中添加此按钮吗?

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-add-the-tumblr-share-button-in-wordpress/

tumblr

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值