Quickly Add PayPal Donate To Posts in WordPress

This creates a PayPal donate shortcode. Drop this function into your theme’s functions.php. Then in any page or post in which you want to add a PayPal donate link, simply type the shortcode:


It will create a simple link, which you can style any way you like with CSS. Be sure to edit lines 4, 5, and 6 below! Use your own PayPal email address on line 5.

// paypal donate shortcode
function donate_shortcode( $atts ) {
        'text' => 'Make a donation', // Your custom anchor text goes here
        'account' => 'you@yourdomain.com', // Your PayPal email goes here
        'for' => 'Dance Field Trip', // Your own cause
    ), $atts));
    global $post;
     if (!$for) $for = str_replace(" ","+",$post->post_title);
     return '<a class="donateLink" href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business='.$account.'&item_name=Donation+for+'.$for.'">'.$text.'</a>';
add_shortcode('donate', 'donate_shortcode');


Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this: