• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WordPress Tips, Code Snippets, and How To Tutorials

  • Home
  • Blog
  • Tips
  • Snippets
  • Tutorials
  • Contact

How to add a Paypal Donate button link to your site using a shortcode

October 10, 2015 by admin Leave a Comment

Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to create a shortcode that allows you to add a Paypal Donate button link on your site.

/**
 * Create Paypal Donate button link using shortcode
 *
 * @author WPSnacks.com
 * @link https://www.wpsnacks.com
 */
function donate_button_shortcode( $atts, $content = null) {
	global $post;extract(shortcode_atts(array(
		'account' => 'your-paypal-email-address',
		'for' => $post->post_title,
		'onHover' => '',
	), $atts));
	if(empty($content)) $content='Make A Donation';
		return '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business='.$account.'&item_name=Donation for '.$for.'" title="'.$onHover.'">'.$content.'</a>';
}
add_shortcode('donate', 'donate_button_shortcode');

Then you can add one of the below shortcodes to add the Paypal Donate link or you can alter the code slightly to add an image button instead of a word link.

[donate]
[donate]Some text here[/donate]
[donate account=”name@yoursite.com” onHover=”Thanks” for=”Title”]
[donate account=”name@yoursite.com” onHover=”Thanks” for=”Title”]Some text here[/donate]

$account shows your paypal email address and $onHover sets anchor title when link is hovered over. Hope this helps, enjoy.

If you like this then you should look up more of our WordPress Tips Code Snippets and Tutorials.

Disclosure: There are affiliate links on posts and throughout the website and if you use the links to make a purchase we may earn a commission from it. We link to these companies and their products because of the quality of the companies and not because of the commission we may receive from it.

Disclaimer: The information contained in this website is for general information purposes only and in no event will this website or its owners be liable for any losses or damages associated with your use of our website or content. We recommend that you make a backup of your website before you make updates to it. Click here to see our full Disclaimer.

Filed Under: Code Snippets Tagged With: Functions.php, Paypal, Shortcodes

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Hey, We Deliver... Anywhere!

Enter Email Address below to receive our snacks via email:

Join Over 1200 Readers!

Jump To A Random WordPress Tip

Copyright © 2019 • wpsnacks.com