Using Google API to add QR Code for WordPress Web Page

Smart phones becoming increasingly popular, website support for mobile phones is becoming more important, QR code can be said to be the most simple and convenient way to deliver the message to the mobile phone, especially transport web URL.

For example: https://xuri.me/, generated for the QR code image URL is https://chart.googleapis.com/chart?chs=220x220&cht=qr&chl=https://xuri.me&choe=UTF-8

https://chart.googleapis.com/chart? is a QR code API address.
cht=qr indicate the type of QR code.
chs=220×220 generated QR code image size.
choe=UTF-8 encoding of the content, the default is UTF-8.
chld=L|2 error correction levels and blank border width. Error correction level from low to high, respectively LMQH, the higher the level, the lower the error rate of the rows and columns of QR code is also more (Google API based on QR code and it will automatically select the appropriate content-length QR code ranks number) (Google API documentation in more detail). Border width can choose.
chl=https://xuri.me/ contents of QR code.

Add a QR code for the web method is very simple, just use the JavaScript window.location.href get the URL and add it to chl=immediately after the code is as follows:

document.write("<img src=\"https://chart.googleapis.com/chart?cht=qr&chs=220x220&choe=UTF8&chld=L|2&chl="+encodeURI(window.location.href)+"\" width=\"220\" height=\"220\"/></img>");

If you want the WordPress Support only need to create a QR code text sidebar gadget and paste the code above into the can.

Using Google API to add QR Code for WordPress Web Page
2 votes, 4.00 avg. rating (84% score)