WordPress

Add Paypal Donate WordPress Shortcode

Paypal

In a previous post we had a snippet on how you can make money on your WordPress blog by placing Google Adsense on your website. This snippet was a shortcode so you can add the Google Adsense anywhere in your content.

In this article there will be another WordPress shortcode on making money by using the Paypal donate functionality. This is when you have a button on your website where people can donate money to you which goes directy into your paypal account.

All you have to do is copy the following in your functions.php file and you can use the shortcode in your content.

function paypal_donate( $atts ) {  
    extract(shortcode_atts(array(  
        'text' => 'Make a donation',  
        'account' => 'Add your account name here',  
        'for' => '',  
    ), $atts));  
  
    global $post;  
  
    if (!$for) $for = str_replace(" ","+",$post->post_title);  
  
    return '<a class="paypal_donate" href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business='.$account.'&item_name=Donation+for+'.$for.'">'.$text.'</a>';  
  
}  
add_shortcode('donate', 'paypal_donate');

Now in your content you can use the shortcode

[donate]
Back to top ^

Join Paulund

  • Get access to 100s of premium tutorials and downloadable content
  • Members content consists of Premium WordPress plugins, CSS packages, jQuery packages, tutorial demo files and templates for 100s of web development tutorials
  • In-depth development tutorials
  • Priority tutorial requests
  • Priority email development support
  • No ads

Here at Paulund you'll find Web Development tutorials and snippets focusing mainly on PHP, WordPress and CSS. Members will get access to premium tutorials that go into more detail about development with these languages. You will also get access to downloadable premium content based on the tutorial.

Join Paulund

Leave a Reply

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