wordpress添加媒体_如何在WordPress中添加社交媒体共享计数小部件

wordpress添加媒体

Earlier on this blog, we created a Social Media Cheat Sheet for WordPress, but that only showed you how to add social media buttons. As social media grows and the web matures, we are seeing less and less of the simple social media buttons. Social media buttons are being replaced by the share count widgets such as tweetmeme retweet widget, digg counter, facebook share and more. In this article, we will show you how you can add different social media share count buttons in WordPress.

在此博客的前面,我们为WordPress创建了一个社交媒体备忘单 ,但仅向您展示了如何添加社交媒体按钮。 随着社交媒体的发展和网络的成熟,我们越来越看不到简单的社交媒体按钮。 社交媒体按钮已被共享计数小部件取代,例如tweetmeme转推小部件,digg计数器,facebook共享等。 在本文中,我们将向您展示如何在WordPress中添加不同的社交媒体共享计数按钮。

抓住原始小部件 (Grab the Original Widget)

Most of the share counts are a piece of JavaScript that you must retrieve from the social media service. This article is also meant to serve as a one stop shop. You can come here to find the location for top social media services because a lot of them makes it really hard to find on their sites. The goal of this article is to avoid using as many plugins as possible, so when you are picking the type choose site: Normal.

大多数共享计数是您必须从社交媒体服务中检索的一段JavaScript。 本文还旨在充当一站式商店。 您可以来这里找到顶级社交媒体服务的位置,因为其中很多使得在他们的网站上很难找到。 本文的目的是避免使用尽可能多的插件,因此在选择类型时,请选择站点:正常。

自定义代码 (Customizing the Codes)

Because we chose the code for a Normal Site, we may need to modify it to make it compatible with WordPress. We are also going to be showing just the Compact Share Count Buttons. You can ofcourse use the codes as a guide to get different sizes.

因为我们选择了“普通站点”的代码,所以我们可能需要对其进行修改以使其与WordPress兼容。 我们还将仅显示紧凑型共享计数按钮。 您当然可以使用代码作为指导来获取不同的大小。

Note: You must paste all of these codes inside a loop, most likely in your single.php file.

注意:您必须将所有这些代码粘贴到循环中,最有可能粘贴在single.php文件中。

掘客 (Digg)

<script type="text/javascript">
(function() {
var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
s.type = 'text/javascript';
s.async = true;
s.src = 'http://widgets.digg.com/buttons.js';
s1.parentNode.insertBefore(s, s1);
})();
</script>

<a class="DiggThisButton DiggCompact" href="http://digg.com/submit?url=<?php the_permalink(); ?>"></a>

Normally, you should not have to add the href part of the link area. But if you don’t, and you have paginated comments or posts, then your digg button will not work on all pages. So if the main page was submitted, the second page will show a submit URL allowing users to submit duplicate content to digg.

通常,您不必添加链接区域的href部分。 但是,如果您没有这样做,并且您已对评论或帖子进行了分页,则digg按钮将无法在所有页面上使用。 因此,如果主页已提交,则第二页将显示一个提交URL,允许用户将重复的内容提交给digg。

偶然发现 (StumbleUpon)

<script src="http://www.stumbleupon.com/hostedbadge.php?s=1&r=<?php the_permalink(); ?>"></script>

Tweetmeme转推 (Tweetmeme Retweet)

<script type="text/javascript">
tweetmeme_source = 'wpbeginner'; tweetmeme_service = 'bit.ly'; tweetmeme_style = 'compact'; tweetmeme_url = '<?php the_permalink() ?>';
</script>
<script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script>

Make sure that you change the Tweetmeme_source variable to your twitter handle. Right now it is @wpbeginner. So whenever someone clicks it will show RT @wpbeginner Post Title – Link. We are using bit.ly as the link shortening service, you can change it to others that tweetmeme offers, but bit.ly is the best one.

确保将Tweetmeme_source变量更改为Twitter句柄。 现在是@wpbeginner。 因此,只要有人单击它,就会显示RT @wpbeginner帖子标题–链接。 我们使用bit.ly作为链接缩短服务,您可以将其更改为tweetmeme提供的其他服务,但是bit.ly是最好的一种。

脸书分享 (Facebook Share)

<a name="fb_share" type="button_count" share_url="<?php the_permalink(); ?>" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>

Facebook的喜欢按钮 (Facebook Like Button)

Facebook Like Button is a phonemonal tool for traffic. Syed has shown how it has helped in our WordPress Newsletter in the past.

Facebook Like Button是用于流量的语音工具。 Syed在过去的WordPress新闻中已展示了它的帮助。

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:60px;"></iframe>

To see more options see How to Add Facebook Like button in WordPress.

要查看更多选项,请参阅如何在WordPress中添加“喜欢Facebook”按钮

Reddit (Reddit)

<script type="text/javascript">
reddit_url = "<?php the_permalink(); ?>";
reddit_title = "<?php the_title(); ?>";
</script>
<script type="text/javascript" src="http://reddit.com/static/button/button1.js"></script>

Njuice Google Buzz计数 (Njuice Google Buzz Count)

Google Buzz do not have an active API that allows to keep track of count. There are a few ways to work around that which gives you some what of a misguided count. But for those users, who want to have a Google Buzz Count, then here is how you can add it.

Google Buzz没有有效的API,无法跟踪计数。 有几种方法可以解决该问题,这给了您一些误导。 但是对于那些想要拥有Google Buzz计数的用户,则可以按以下方法添加它。

<script type="text/javascript">
var njuice_buzz_size = 'small';
var njuice_buzz_title = '<?php the_title(); ?>';
var njuice_buzz_url = '<?php the_permalink(); ?>';
</script>
<script type="text/javascript" src="http://button.njuice.com/buzz.js"></script>

斯宾 (Sphinn)

<script type="text/javascript">submit_url = '<?php the_permalink(); ?>';</script>
<script type="text/javascript" src="http://sphinn.com/evb/buttons.php?b=small"></script>

领英按钮 (LinkedIn Button)

<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share" data-url="<?php the_permalink(); ?>" data-counter="top"></script>

Source: How to Add Official LinkedIn Button in WordPress

来源: 如何在WordPress中添加官方LinkedIn按钮

That is all the customizing we need to make each of these widgets work with WordPress perfectly. Now, you may have to customize the styling for it to work with your theme design. You are better of putting these codes above <?php the_content(); ?> code. You can also use our Smart Sharing Plugin, to display a floating icon down your window.

这就是我们需要做的所有自定义操作,以使这些小部件都能与WordPress完美配合。 现在,您可能必须自定义样式以使其与主题设计一起使用。 您最好将这些代码放在<?php the_content();之上 ?>代码。 您还可以使用我们的智能共享插件 ,在窗口下方显示一个浮动图标。

Do you have any other social media widgets that you would like to add? Let us know, and we can get the codes here. If you are using another widget and have the code ready, then please submit it to us, so others can benefit from it as well.

您还有其他社交媒体小部件要添加吗? 让我们知道,我们可以在这里获取代码。 如果您正在使用其他窗口小部件并准备好代码,请将其提交给我们,以便其他人也可以从中受益。

翻译自: https://www.wpbeginner.com/wp-themes/how-to-add-social-media-share-count-widgets-in-wordpress/

wordpress添加媒体

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值