如何在WordPress中添加WhatsApp共享按钮

Messaging apps like WhatsApp are becoming a new way to share things with friends. Recently one of our users asked us how they can add a WhatsApp share button in their posts. In this article, we will show you how to add WhatsApp share button in WordPress.

诸如WhatsApp之类的消息传递应用程序正在成为与朋友共享事物的新方式。 最近,我们的一位用户问我们如何在其帖子中添加WhatsApp共享按钮。 在本文中,我们将向您展示如何在WordPress中添加WhatsApp共享按钮。

WhatsApp
影片教学 (Video Tutorial)

演示地址

If you don’t like the video or need more instructions, then continue reading.

如果您不喜欢该视频或需要更多说明,请继续阅读。

First thing you need to do is install and activate the WhatsApp Share Button plugin. Upon activation, you need to visit Settings » WhatsApp Share Button to configure the plugin.

您需要做的第一件事是安装并激活WhatsApp共享按钮插件。 激活后,您需要访问设置»WhatsApp共享按钮来配置插件。

Setting up WhatsApp Share Button plugin for WordPress
在WordPress中自动显示WhatsApp共享按钮 (Automatically Show WhatsApp Share Button in WordPress)

The plugin allows you to add WhatsApp share button both manually and automatically.

该插件可让您手动和自动添加WhatsApp共享按钮。

If you want to automatically display the button, then you need to check the options where you want it to be displayed.

如果要自动显示按钮,则需要检查要显示按钮的选项。

Note: the plugin uses CSS code to detect a user’s screen size and will only show the WhatsApp button to users whose screen size is less than 1024px. If you are testing the plugin on your laptop, then you need to resize your browser screen until you see the button.

注意:该插件使用CSS代码检测用户的屏幕尺寸,并且只会向屏幕尺寸小于1024px的用户显示WhatsApp按钮。 如果要在笔记本电脑上测试插件,则需要调整浏览器屏幕的大小,直到看到该按钮。

You can choose to show it on your posts, pages, and homepage. You can also choose the location of the button to be before or after the post content.

您可以选择将其显示在您的帖子,页面和主页上。 您还可以将按钮的位置选择为帖子内容之前或之后。

The last option on the settings page adds a utm parameter to the shared link. This is particularly useful for tracking links in Google Analytics.

设置页面上的最后一个选项将utm参数添加到共享链接。 这对于跟踪Google Analytics(分析)中的链接特别有用。

Once you are satisfied with the options, click on the save button to store your settings.

对选项满意后,单击“保存”按钮以存储您的设置。

使用简码手动添加WhatsApp共享按钮 (Manually Add WhatsApp Share Button Using Shortcode)

WhatsApp Share Button plugin comes with a shortcode, that you can add anywhere on your WordPress site to display the WhatsApp Share button.

WhatsApp Share Button插件带有一个简码 ,您可以在WordPress网站上的任意位置添加以显示WhatsApp Share按钮。

Simply add [whatsapp] to your posts and pages where you want to display the button.

只需将[whatsapp]添加到要显示按钮的帖子和页面即可。

You can also use the shortcode inside a Text widget. By default, WordPress does not allow execution of shortcodes inside text widgets however you can enable this by adding a little code snippet into your theme’s functions.php file or a site-specific plugin.

您也可以在“文本”小部件内使用简码。 默认情况下,WordPress不允许在文本小部件内执行短代码,但是您可以通过在主题的functions.php文件或特定站点的插件中添加一些代码片段来启用此功能


add_filter('widget_text', 'do_shortcode');

使用简码在WhatsApp中共享任何URL (Using The Shortcode To Share Any URL in WhatsApp)

By default, the shortcode [whatsapp] automatically uses the URL of the currently displayed post or page. However, you can override this and add any URL that you want your users to share by using a shortcode like this:

默认情况下,简码[whatsapp]自动使用当前显示的帖子或页面的URL。 但是,您可以使用以下短代码覆盖此内容并添加您希望用户共享的任何URL:

[whatsapp title=”WPBeginner” url=”https://www.wpbeginner.com”]

[whatsapp title =“ WPBeginner” url =“ https://www.wpbeginner.com”]

That’s all. We hope this article helped you learn how to add a WhatsApp share button in WordPress. You may also want to see our list of 21 best social media monitoring tools for WordPress users.

就这样。 我们希望本文能帮助您学习如何在WordPress中添加WhatsApp共享按钮。 您可能还想查看我们为WordPress用户提供的21种最佳社交媒体监视工具列表。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/plugins/how-to-add-whatsapp-share-button-in-wordpress/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. 在前端增加右下角的询盘表单弹窗 可以使用以下步骤实现: 1. 在WordPress的主题文件打开 functions.php 文件,添加以下代码: ``` function add_popup_form() { ?> <div id="popup-form-container"> <form id="popup-form" method="post" action=""> <label for="name">Name:</label> <input type="text" id="name" name="name" required> <label for="email">Email:</label> <input type="email" id="email" name="email" required> <label for="message">Message:</label> <textarea id="message" name="message"></textarea> <input type="submit" value="Submit"> </form> </div> <?php } add_action('wp_footer', 'add_popup_form'); ``` 2. 将上面代码的表单内容进行自定义修改,比如修改表单项的名称,添加更多的表单项等。 3. 在 WordPress 的主题样式文件(style.css)添加以下 CSS 代码,以控制弹窗的显示和样式: ``` #popup-form-container { position: fixed; bottom: 0; right: 0; width: 300px; height: 400px; background-color: #fff; border: 1px solid #ccc; z-index: 9999; display: none; } #popup-form-container form { padding: 20px; } #popup-form-container label { display: block; margin-bottom: 10px; } #popup-form-container input, #popup-form-container textarea { display: block; width: 100%; margin-bottom: 20px; } #popup-form-container input[type="submit"] { background-color: #333; color: #fff; border: none; padding: 10px 20px; cursor: pointer; } ``` 4. 最后,使用 JavaScript 代码监听点击事件,显示和隐藏弹窗: ``` jQuery(document).ready(function($) { $('#popup-form-container').fadeIn(); }); $('#close-button').click(function(e) { e.preventDefault(); $('#popup-form-container').fadeOut(); }); ``` 2. 在前端的右侧增加在线悬浮窗口 可以使用以下步骤实现: 1. 在 WordPress 的主题文件打开 functions.php 文件,添加以下代码: ``` function add_whatsapp_button() { ?> <div id="whatsapp-button"> <a href="https://wa.me/8518588629881" target="_blank"><img src="path/to/whatsapp-icon.png" alt="WhatsApp"></a> </div> <?php } add_action('wp_footer', 'add_whatsapp_button'); ``` 2. 修改代码WhatsApp 号码,以及 WhatsApp 图标的路径。 3. 在 WordPress 的主题样式文件(style.css)添加以下 CSS 代码,以控制按钮的显示和样式: ``` #whatsapp-button { position: fixed; right: 20px; bottom: 20px; z-index: 9999; } #whatsapp-button img { width: 50px; height: 50px; } ``` 3. 实现后台的排版 可以使用以下步

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值