Home / functions.php / Paypal donation shortcode
  • How to Paypal donation shortcode

    paypal-donation-shortcode

    Adding the first block of code to the functions.php of your wordpress theme will allow you to use the following shortcode for donation links within your blog.

    ( click code to copy )

    wordpress snippet : PHP

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

    wordpress snippet : SHORTCODE

    <>
    [donate]
    [donate]Donate Now[/donate]
    [donate account="you@yoursite.com" onHover="Thanks" for="Title"]
    [donate account="you@yoursite.com" onHover="Thanks" for="Title"]Donate Now[/donate]
    

    ( WordPress codex functions, hooks, in this snippet. )

    add_shortcode, shortcode_atts, _x, _n,