How to Add a QR Code to WordPress Posts (Plugin and Code, 2026)
Want to add a unique QR code to WordPress posts so phone users can open or share the page in one scan? In 2011 we showed how to do this with one line of code using the Google Chart API. Google has since shut that API down, so the old code shows a broken image. Here are working ways to add a QR code to every WordPress post in 2026, with or without a plugin.

Quick answer: The easiest way is a plugin such as Kaya QR Code Generator: add the shortcode [kaya_qrcode] to a post, widget or template and it shows a QR code for the current page URL. Without a plugin, add an image tag in your theme that calls a QR image API with the post permalink, or generate the code in the browser with a small JavaScript library.
Table of Contents
Why add QR codes to posts?
- Readers on a desktop can scan to continue reading on their phone.
- Printed pages, slides and posters can carry a scannable link.
- Event pages, menus, product pages and downloads become easy to open on mobile.
Tip: Chrome and Edge already have a built-in Create QR code option in the share or address-bar menu, so many visitors can make their own. Adding one to your page simply makes it obvious.
Method 1: Use a QR code plugin (easiest)
- Go to Plugins > Add New and install Kaya QR Code Generator or a similar plugin.
- Add the shortcode
[kaya_qrcode]where you want the code. With no content, it uses the current page URL automatically. - To show it on every post, add the shortcode to a widget area, or to your single post template in the Site Editor using a Shortcode block.
Method 2: Add a QR image to your theme (no plugin)
This replaces our old Google Chart code. Add it to your classic theme’s single.php (in a child theme) where you want the QR code:
<img src="https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=<?php echo urlencode( get_permalink() ); ?>" width="150" height="150" alt="QR code for this post" loading="lazy" />- size sets the image size, for example 150×150 or 200×200. Very small codes are hard to scan.
- data is the URL to encode;
urlencode()keeps special characters safe. - This uses a third-party service from goQR.me, so check its terms and remember the service sees which URLs are requested.
Method 3: Generate QR codes in the browser
For full privacy and no external requests, load a small open-source library such as QRCode.js and create the code from the page URL with a few lines of JavaScript. It works on any theme, including block themes, via a Custom HTML block.
QR code tips
- Keep a white margin (quiet zone) around the code.
- Use dark code on a light background for reliable scanning.
- Use short URLs when possible; shorter data means a simpler code. See how to make branded short URLs.
- Test with both an iPhone and an Android camera before printing.
QR codes are also handy for offline blog promotion on business cards and flyers.
FAQ
Does the Google Chart API still make QR codes?
No. Google deprecated its image charts, including QR codes, and turned them off, so old chart.apis.google.com code no longer works.
Do QR codes expire?
A static QR code that encodes your URL directly never expires. Dynamic QR codes from paid services stop working if the subscription ends.
Can I add a QR code without a plugin?
Yes. Use the theme code above or a JavaScript library in a Custom HTML block.







Hi, thank you for that nice article to use google Chart API for QR Codes. Sometimes one is not interestend in using Google for tooo many thing in life. We set up an own WordPress plugin which does not work with Googles’ API. If it’s interesting for someone take a look at: https://wordpress.org/plugins/wpqr-qr-code/
Nice Tip! This code can be brought to several uses. Thanks for sharing.
Create post, yes I think this is a must actually I created a plugin to do that many moons ago it is in a google code project, https://code.google.com/archive/p/qr-code-plugin-wordpress
Just forgot to tell people about it