Using the following snippet will let you add PayPal button to your WordPress website. Remember to add the snippet to your theme’s functions.php file and you are done.
1 2 3 4 5 6 7 8 9 10 11 | function cwc_donate_shortcode( $atts ) { extract(shortcode_atts(array( 'text' => 'Make a donation', 'account' => 'REPLACE ME', 'for' => '', ), $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', 'cwc_donate_shortcode'); |
Snippet Source/Credit: Snipplr