How to add a PayPal Donate Button Shortcode in WordPress

PayPal Donate Buttons are a fast and easy way to accept online donation payments for your WordPress blog or site. One simple button will allow you to easily accept credit cards, debit cards, and PayPal. Adding a PayPal Donate button to your website is pretty simple but can be simplified even further by utilizing a WordPress function to create a custom shortcode that can then be inserted into any page or post. In this tutorial we will teach you how to create a PayPal Donate Button shortcode in WordPress via a PHP function.

Step 1: Create the PayPal Donate Button Shortcode via a WordPress Function

In order to create the PayPal Donate Button shortcode we will need to add a PHP filter to the WordPress functions file. Open your functions.php file then copy and paste the code below. Reference the ‘Items to Note’ below in order to adjust the code to work with your specific PayPal Account.


function donate_shortcode( $atts, $content = null) {
	global $post;extract(shortcode_atts(array(
		'account' => 'YOUR-ACCOUNT-HERE',
		'for' => $post->post_title,
	), $atts));
	return '<a href="'.$account.'&item_name=Donation for '.$for.'" target="_blank"><img src="" alt="PayPal - The safer, easier way to pay online!" /></a>';
add_shortcode('donate', 'donate_shortcode');

Items to Note:

  • Make sure that you change where it says ‘YOUR-ACCOUNT-HERE’ to your actual PayPal account name.
  • The ‘for’ variable will automatically grab the Page/Post Title and insert it into the PayPal Donate Button code.

Step 2: How to use the PayPal Donate Button Shortcode in a WordPress Page or Post

Now that the PayPal Donate Button shortcode has been created, it can now be inserted into any page or post. Simply copy the shortcode below and paste it inside the content editor wherever you want the PayPal Donate Button to appear.



PayPal Donate Button Example

If you liked this tutorial and found it helpful please feel free to leave us a donation.

PayPal - The safer, easier way to pay online!


If you are having problems getting this tutorial to work please reread the tutorial and try again, if you still cannot get it to work please leave us a comment below and we will respond as soon as possible. Please do not email us with problems regarding this tutorial, only comments will be responded to.