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

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
 * @link
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="'.$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]Some text here[/donate]
[donate account=”” onHover=”Thanks” for=”Title”]
[donate account=”” 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.

   Related Sponsored Links

Disclaimer: The information contained in this website is for general information purposes only and in no event will this site or its owners be liable for any losses or damages associated with your use of our site or content. Click here to see our full Disclaimer.

Leave a Comment