How to Add QR Codes to Blog Posts in WordPress

QR Codes

Have you seen QR codes shown in blog posts? Have you ever thought why this is done? We are already online, and we are reading the post, so why we need a QR code?

QR (Quick Response) code is used to give an identity to your product, so that people can get quick access to the details of the product or directly get into the website using a Smartphone. Smartphones are now common, and they need no extra hardware to read the QR code which makes it easy to use and efficient than typing a URL in your browser.

Now it’s a common practice to use QR codes in blog posts and websites. It mainly has two uses.

1. It helps to share the post easily.

When we are required to share the post through some printed material or posters, QR codes can help to make it easier. A QR code can be directly linked to your blog posts. It is far better providing a QR code rather than providing a URL of your post. It is easy and quick to share, and it won’t take much space.

2. It makes your post more accessible.

Reading a complete post may take some time depending upon its length and depth. If a reader who is in a hurry wants to read the whole post or if they want to save the post for reading it later, QR code can help you do that. Just scan the QR code in your Smartphone and bookmark it. This would save a lot of time.

QR codes can be generated free of cost, and it only costs a small space to embed it. But all its applications make it worth to use.

How to show QR code in the posts:

There are basically two ways to show a QR code in your blog posts.

1. Adding code to Single.php file

In this method, we edit the Single.php file and add a small piece of code to it. Remember that editing the theme files is not recommended for those who are not familiar with coding as it can cause your site to go down. So take necessary backups before trying this method.

Add following code to ‘single.php’ file.

1
<img alt="QR code" src="http://chart.apis.google.com/chart?cht=qr&amp;chs=150x150&amp;chld=L|4&amp;chl=&lt;?php the_permalink(); ?&gt;" width="150" height="150" />

You can add this code wherever you want to insert the QR code image. This method use Google Chart API to generate the QR code. The Size of the QR code image can be changed by changing the values for &chs. Here it is 150X150.

2. Modifying functions.php file

Add the the following code into ‘functions.php‘ file.

1
2
3
4
5
6
7
8
function currentpage_qr_code( $atts ) {
    extract(shortcode_atts(array(
        'size' =&gt; '300'
    ), $atts)); 
    global $post;  
    return '<img alt="&quot;'.$post-" src="http://api.qrserver.com/v1/create-qr-code/?size='.$size.'x'.$size.'&amp;data='.get_permalink( $post-&gt;ID ).'" />post_title.'"/&gt;';  
}
add_shortcode('qrcurrent', 'currentpage_qr_code');

Now add the short code [qrcurrent] anywhere in your post to generate the QR code and to show the same in your post.

3. Using Plugins

For those who are afraid to play with theme files, there are lots of plugins which can help you generate a QR code for your posts. You can either add them in your posts or in the sidebar. Here are some of the best plugins for generating QR codes.

WPQR QR-Code Generator

1. After installation and activation of this plugin, you can add the QR code in your blog post by simply adding a short code [qr-code] anywhere in your post.

You can either add the QR code along with your post or in the sidebar.

2. You can find an option, under the Settings menu in the dashboard, named – QR code. This page provides a code which can be used to customize the QR code.

3. To add the QR code in your sidebar, Go to Appearance-> Widget and put the QR code widget in the sidebar, wherever you want it to be shown. You have options to customize the area there itself.

Some other good alternative plugins are QR Code Generator 4 All & WCS QR Code Generator.

QR codes can help you increase your page views and will be useful for your readers to access your web pages through Smart phones.

So why not give it a try? Do you prefer showing QR codes in your blog posts? Do share your comments about this post.

Get New Posts In Your Email

Leave a Reply