Revision 250 is a pre-publication revision. (Viewing current revision instead.)

Create QR Codes For 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. [html]http://api.qrserver.com/v1/create-qr-code/?size=150x150&data=url-or-text[/html] 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. [php]function currentpage_qr_code( $atts ) { extract(shortcode_atts(array( 'size' => '300' ), $atts)); global $post; return '<img src="http://api.qrserver.com/v1/create-qr-code/?size='.$size.'x'.$size.'&data='.get_permalink( $post->ID ).'" alt="'.$post->post_title.'"/>'; } add_shortcode('currentqr', 'currentpage_qr_code');[/php] Add the shortcode anywhere in your posts to generate a QR code for the current page. [php][currentqr][/php] All you have to do is scan this QR with your mobile and you will be able to see this page on your phone.

Revisions

  • August 10, 2012 @ 07:44:25 [Current Revision] by PeterLugg
  • August 10, 2012 @ 07:42:12 by PeterLugg

Revision Differences

August 10, 2012 @ 07:42:12Current Revision
Content
 Added: QR can be used by mobile devices to scan and get bits of data, they can even be used to display a web page.
 Added: They are starting to become more and more popular the more mobile devices are being used.
 Added: 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.
 Added: [html]http:// api.qrserver.com/v1/create- qr-code/?size= 150x150&amp; data=url-or-text[/html]
 Added: WordPress Shortcode
 Added: 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.
 Added: Just copy and paste the following into your functions.php page to create the shortcode.
 Added: [php]function currentpage_qr_code( $atts ) {
 Added: extract(shortcode_atts(array(
 Added: 'size' =&gt; '300'
 Added: ), $atts));
 Added: global $post;
 Added: return '&lt;img src=&quot;http: //api.qrserver.com/v1/create- qr-code/?size= '.$size.'x'.$size.'&amp; data='.get_permalink( $post-&gt;ID ).'&quot; alt=&quot;'.$post- &gt;post_title.'&quot;/&gt;';
Deleted: Added: }
 Added: add_shortcode( 'currentqr', 'currentpage_ qr_code');[/php]
 Added: Add the shortcode anywhere in your posts to generate a QR code for the current page.
 Added: [php][currentqr][/php]
 Added: All you have to do is scan this QR with your mobile and you will be able to see this page on your phone.

Note: Spaces may be added to comparison text to allow better line wrapping.

Tags:

No comments yet.

Leave a Reply