Available variables
Use in form: [qrcode variable1="value" variable2="value"]text[/qrcode]
Variable name | Description | Default value | Acceptable values |
text | The text you want to encode into QR. Please bare in mind that if you define tel, sms, email or link variables they will overwrite this one. | none | Any text shorter than 4000 characters. |
tel | Telephone number you want to embed in QR. Overwrites other content vars: text, email, sms, link. | none | Telephone number in any format, ie: +1 456 345 232 |
sms | Upon scanning the code user will be prompted to send an SMS to this number. Overwrites other content vars: text, email, tel, link. | none | Telephone number in any format, ie: +1 456 345 232 |
Upon scanning the code user will be prompted to send an email to this address. Overwrites other content vars: text, sms, tel, link. | none | Email address. Some QR readers also support email@address.com? subject=something. | |
link | Link you want to embed in QR. Overwrites other content vars: text, email, sms, tel. | none | Link, with or without http:// prefix. |
size | Size of QR Code in pixels. QR is always a square; so this is both width and height. | 150 | Any positive integer. |
border | Border size. In code rows, not pixels. | 1 | Any positive integer. |
background | Background color. Shown only on border part of the image. Actual image colors can’t be changed. It’s always black on white. | FFFFFF | Hex color code, 6 chars |
class | Image CSS class. | qrcode | String, any acceptable CSS class name. |
title | Image alt/title. If not defined will default to QR text. | none | String, any acceptable image alt/title value. |
Variables you probably won’t need: | |||
level | Error correction level. It’s automatically configured. Define only if you want to enhance the probability of recovery in chance of miss read QR code on end-user device. | l | l, m, q, h |
post_id | If you’re using custom field values in a non-single page or want to force another post ID besides the post you’re currently in then specify this variable. | current post, page, custom post type ID | int; any valid post, page, custom post type ID |
debug | Prints out various variables used in the process of QR code defining/creation. | false | true, false |
Using custom fields for variable values
Instead of the usual variable=”value” use variable=”$custom-field-name” where custom-field-name is the actual custom field in the current post/page/custom post type.
The only thing to remember is: place the dollar sign ($) in front of custom field name.
Example: [qrcode size="$size"]$my-txt[/qrcode]
The post ID will be auto-detected, but if needed, enter it manually via “post_id” parameter.
Using post properties
The following post/page variables/properties are available to use in any part of QR codes:
- {post->id} – post ID
- {post->title} – post title
- {post->date} – post publishing date
- {post->author} – post author nice name
- {post->permalink} – post permalink, complete URL
- {post->comments} – number of comments
Example: [qrcode]{post->title} by {post->author}[/qrcode]
Usage in template files
We’ve provided two PHP functions which you can use anywhere in templates or PHP in general:
string get_qrcode($shortcode) null the_qrcode($shortcode)
First one returns the output while the other one outputs it. Usage is simple. Just put the usual complete shortcode txt as the functions parameter:
Look at my QR: <?php the_qrcode('[qrcode size="300"]my-txt[/qrcode]'); ?> Ain't it fancy?
[…] updated – now with post properties/variables support […]