RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.20% (5.24%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.20% (5.24%*) • Investment IO: 5.63% (6.88%*) • Investment PI: 5.49% (6.32%*)

Create QR Codes with Google Charts & WP Shortcode

QR codes are a popular type of two-dimensional barcode. They are also known as hardlinks or physical world hyperlinks. QR Codes store up to 4,296 alphanumeric characters of arbitrary text. This text can be anything, for example URL, contact information, a telephone number, even random text. QR codes can be read by an optical device with the appropriate software. Such devices range from dedicated QR code readers to mobile phones (if you have a barcode scanner application it's likely it already reads QR codes).

This snippet is to support an article on our website: Include QR Codes on Your Website.

The following code utilizes the Google Charts API to render the resulting code.

1
<?php 
2
/*
3
 Create QR Codes with Google Charts
4
 Article: Include QR Codes on Your Website
5
 http://www.beliefmedia.com/qr-codes-website
6
*/
7
 
8
function beliefmedia_google_qrcode($atts) {
9
 
10
  $atts = shortcode_atts(array(
11
    'url' => 'Hello World',
12
    'w' => '150',
13
    'ec' => 'L',
14
    'margin' => '0',
15
  ), $atts);
16
 
17
 return '<img src="http://chart.apis.google.com/chart?chs=' . $atts['w'] . 'x' . $atts['w'] . '&cht=qr&chld=' . strtoupper($atts['ec']) . '|' . $atts['margin'] . '&chl=' . urlencode($atts['url']) . '" alt="' . $atts['alt'] . '" width="' . $atts['w'] . '" />';
18
}
19
add_shortcode('gqr', 'beliefmedia_google_qrcode');

Usage is as follows: [gqr url="http://www.beliefmedia.com/"]. The result of this shortcode is as follows (centering is ours):

PHP version here.

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  AUS Eastern Standard Time (California)

  Want to have a chat?
 

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment