为WordPress页面快速创建PAYPAL付款按钮技巧

建站资源209阅读模式

如果我们有阅读他人博客的习惯可能会经常看到有些老外的博客页面中和某些位置加入PAYPAL的按钮,可以用来创建付费的产品销售,也可以用于对于博客支持的捐款快速链接。这样的按钮效果是如何做上去的呢?如果我们使用的是WORDPRESS程序,我们可以在主题FUNCTIONS.PHP文件中创建自定义快速链接,然后在需要调用按钮的位置用短代码实现。

这里老董就分享为WordPress页面快速创建PAYPAL付款按钮技巧,如果我们的博客中有需要加上也可以跟着加上这样的功能。

第一、安装插件

我们需要先安装WP PayPal Payment Plugin插件,如果你没有安装可以安装他,这个插件可以在侧边栏调用PAYPAL的按钮功能。

第二、编辑functions.php文件

在我们当前主题中的functions.php文件中,加入下面的代码。

add_filter('wppp_widget_email', 'custom_payment_widget_email');
function custom_payment_widget_email($email){
$email = get_the_author_meta('user_email');
return $email;
}

add_filter('wppp_widget_any_amt_email', 'custom_payment_any_amt_widget_email');
function custom_payment_any_amt_widget_email($email){
$email = get_the_author_meta('user_email');
return $email;
}

第三、应用到任何页面

我们可以使用短代码把需要显示PAYPAL按钮的页面中,只需要插入下面代码就可以实现。

<?php echo do_shortcode('[wp_paypal_payment_box email="" options="Payment 1:15.50|Payment 2:30.00|Payment 3:50.00"]'); ?>

注意:我们可以根据自己的需要修改汇率比例,以及关联的邮箱地址账户。

 
  • 本文由 老董 发表于 2014 年 8 月 26 日 15:53:12
  • 转载请务必保留本文链接:https://www.laodong.me/wp-paypal-button/