Are you looking for a way to use the PayPal donation shortcodes for donation links within your blog? While there’s probably a plugin for this, we have created a quick code snippet that allows you to use PayPal donation shortcode in WordPress.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin.
This code comes with three different attributes: account
, onHover
, and for
. The account
attribute receives your paypal email address (the default is your admin email address), the onHover
attribute sets the anchor title attribute that displays when you hover over the link, and the for
attribute is the title of the donation (the default is your post title).
<?php function donate_shortcode( $atts, $content = null) { global $post;extract(shortcode_atts(array( 'account' => 'your-paypal-email-address', 'for' => $post->post_title, 'onHover' => '', ), $atts));</p> <p>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_shortcode'); ?>
These are the PayPal donation shortcodes. You can change the emails in the code below:
[donate] [donate]Donate Now[/donate] [donate account="[email protected]" onHover="Thanks" for="Title"] [donate account="[email protected]" onHover="Thanks" for="Title"]Donate Now[/donate]
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 43 best WordPress photography themes and how to create a contact form in WordPress.
[…] This post was mentioned on Twitter by HN Firehose and wp_freak, WPSNIPP. WPSNIPP said: #wordpress Paypal donation shortcode http://bit.ly/e7dnmj #blog please RT 🙂 […]
WordPress Paypal donation shortcode – wpsnipp.com WordPress code snippets for your blog…
Add Paypal donation button to your posts using shortcode…