Shortcode: Generate QR Code Image of your post/page

Add following code where you want to display it.

Usage

[qr_code]

Add following snippet to “functions.php”

Snippet

add_shortcode('qr_code', 'the_qr_code');
function the_qr_code($atts) {
    extract(shortcode_atts(array(
	      'width' => '100',
	      'height' => '100',
     ), $atts));
     return '<img src="http://api.qrserver.com/v1/create-qr-code/?size='.$width.'x'.$height.'&data='.get_permalink().'" alt="QR:  '.get_the_title().'"/>';
}

Result

You will get a QR Image similar to following

qrcode

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>