Below, you’ll find a detailed guide on how to add the QR Redirector Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the QR Redirector Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the QR Redirector Plugin and the shortcodes it provides:
![Plugin Icon](https://ps.w.org/qr-redirector/assets/icon-128x128.png?rev=2782530)
"QR Redirector is a WordPress plugin that enables the creation and management of QR codes for seamless redirection to specified URLs. Simple, practical, and user-friendly."
- [qr-code]
QR Redirector [qr-code] Shortcode
The QR-Redirector plugin shortcode ‘qr-code’ generates a QR code image. It does this by extracting the ‘id’ attribute from the shortcode and retrieving the QR image URL associated with that post ID. If no ‘id’ is specified, no output is displayed.
Shortcode: [qr-code]
Parameters
Here is a list of all possible qr-code shortcode parameters and attributes:
id
– Unique identifier for the specific QR code image
Examples and Usage
Basic example – Display a QR code by specifying the post ID
[qr-code id=2 /]
Advanced examples
Display multiple QR codes by specifying different post IDs. Remember, each QR code should be associated with a unique post ID.
[qr-code id=2 /]
[qr-code id=3 /]
[qr-code id=4 /]
Note: If no ID is specified or if the specified ID is not associated with any QR code, the shortcode will not display anything.
Also, ensure that the ‘qr_image_url’ custom field is set for the specified post ID, as this is where the shortcode retrieves the QR code image URL.
Remember to replace ‘2’, ‘3’, and ‘4’ with the actual post IDs that are associated with the QR codes you want to display.
PHP Function Code
In case you have difficulties debugging what causing issues with [qr-code]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'qr-code', 'qr_show_code');
Shortcode PHP function:
function qr_show_code($atts) {
extract( shortcode_atts( array(
'id' => ''
), $atts ) );
//if no id is specified, we have nothing to display
if(!$id) {
return false;
}
$output = '';
$img = get_post_meta($id, 'qr_image_url', true);
$output .= '<img src="'.$img.'" class="qr-code" />';
return $output;
}
Code file location:
qr-redirector/qr-redirector/qr-redirector.php
Conclusion
Now that you’ve learned how to embed the QR Redirector Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply