A QR code plugin is one more thing to update and one more thing that can break on a WordPress upgrade. For a code that sits on a page, an image URL does the same job and survives theme changes.
The Custom HTML snippet
Paste this into a Custom HTML block, or a Custom HTML widget in a sidebar or footer:
<a href="https://qrcodesforever.com/">
<img src="https://qrcodesforever.com/qr.svg?url=example.com"
alt="QR code for example.com" width="200" height="200">
<br>QR code by QR Codes Forever
</a>
Change example.com to your link. The surrounding link is optional credit; keep it if you're happy to. If your link contains &, ?, # or spaces, encode it first, or copy the embed code from the generator, which does that for you.
Other kinds of code
Swap the part after qr.svg?. The right-hand column is what each code holds:
After qr.svg? | The code contains |
|---|---|
ssid=Shop%20Guest&password=welcome123 | WIFI:T:WPA;S:Shop Guest;P:welcome123;; |
type=whatsapp&whatsapp=919876543210&message=Hi | https://wa.me/919876543210?text=Hi |
q=Your%20Shop%20Name%2C%20City | a Google Maps search for your shop |
upi=shop@okaxis&amount=250 | upi://pay?pa=shop@okaxis&am=250.00&cu=INR |
A Wi-Fi password in a public page's HTML is readable by anyone who views the source, so only post one for a guest network. Inside HTML, & between parameters is the strictly valid form, though browsers accept a plain &. Full list: parameter reference.
A QR code on every post (PHP)
Add this to a child theme's functions.php to put a code at the end of every post, so readers on a computer can continue on their phone:
add_filter('the_content', function ($content) {
if (!is_singular('post') || !in_the_loop() || !is_main_query()) {
return $content;
}
$src = 'https://qrcodesforever.com/qr.svg?url=' . rawurlencode(get_permalink());
$qr = '<p><img src="' . esc_url($src) . '" alt="QR code for this post" width="140" height="140"></p>';
return $content . $qr;
});
rawurlencode makes the permalink safe inside the image URL, and esc_url makes the whole URL safe inside HTML. A child theme keeps the filter from vanishing at the next theme update.
Weight and size
Our SVGs for short links come out around 11 KB. Denser codes weigh more: a contact card with a name, phone and email is about 49 KB. Each one is sent with a one-year cache header, so returning visitors don't download it again.
On screen, 150 to 250 pixels wide scans easily. For flyers printed from the page, the size calculator gives the printed size for the distance people will stand. The same image URL works in Notion and in plain HTML.