Create QR Codes For Your WordPress Posts

QR can be used by mobile devices to scan and get bits of data, they can even be used to display a web page.

They are starting to become more and more popular the more mobile devices are being used.

But creating your own QR codes can be difficult and if you want one for each post of your blog it can be very time consuming. There is a company called QR-Server which provide an API to create QR codes, all you have to do is query this API with the width and height of the QR code you want, the website you want it to redirect to and it will generate a QR code for you.


Paulund QR Code

WordPress Shortcode

Using this API we can create a QR code for any page, now we are going a WordPress shortcode to generate the QR of the current page.

Just copy and paste the following into your functions.php page to create the shortcode.

function currentpage_qr_code( $atts ) {
        'size' => '300'
    ), $atts)); 

    global $post;  

    return '<img src="http://api.qrserver.com/v1/create-qr-code/?size='.$size.'x'.$size.'&amp;data='.get_permalink( $post->ID ).'" alt="'.$post->post_title.'"/>';  

add_shortcode('currentqr', 'currentpage_qr_code');

Add the shortcode anywhere in your posts to generate a QR code for the current page.


Create QR Codes For Your WordPress Posts

All you have to do is scan this QR with your mobile and you will be able to see this page on your phone.

Back to top

Fastest WordPress Hosting With WPEngine

Stunning speed, powerful security, and best-in-class customer service. At WP Engine.

Risk free for 60 days