Peak Positions SEO Logo 231-922-9460

Easy PayPal Donation Shortcode for Your WordPress Website

November 12th, 2021

Simplify the process of receiving donations on your WordPress website with this user-friendly PayPal donation shortcode. This shortcode will make it easy to add a donation link to your website and make it easier to collect support from your audience.

Add this snippet of code to your themes functions.php file:

function donate_shortcode( $atts, $content = null) {
global $post;extract(shortcode_atts(array(
'account' => 'your-paypal-email-address',
'for' => $post->post_title,
'onHover' => '',
), $atts));
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');

Customize the Shortcode

You can change the default “Make A Donation” text to something more fitting for your site, such as “Support Us” or “Donate Now.” You can also customize the ‘item_name’ attribute to provide more context about the donation.

Adding CSS classes or inline styles to the anchor tag will help to match your site’s design. This allows you to control the link’s appearance, including colors, fonts, and hover effects.

If you have a specific PayPal donation URL, you can replace the hardcoded URL with your custom URL.

You can also expand the shortcode to accept more attributes, such as ‘currency’ or ‘amount’, allowing you to set different currency options or predefined donation amounts.

Do you need help optimizing your website to ensure your audience can find and donate to you easily? Contact our SEO Consulting experts today.

TOP 20 SEO COMPANY WORLDWIDE SIX YEARS IN A ROW

Our SEO firm is comprised of a world class team of qualified coders, web designers, developers & SEO copywriters who strive to bring clients the highest quality SEO services in the industry.

Free Website Audit
Top 20 SEO Company Worldwide
  • Dell Logo
  • Ferris State University Logo
  • Sony Logo
  • Primerus Logo
  • Detroit Medical Center Logo
  • Tenet Health Logo
Contact Us

Peak Positions SEO
10850 East Traverse Highway, Suite 2290
Traverse City, MI 49684

231-922-9460

info@peakpositions.com