Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/mmrtxd/nutritionlabels/archive/refs/heads/master.zipNutrition Labels for WordPress
Add nutrition label management, short URLs, and QR code generation to your WooCommerce or WordPress products.
Description
Nutrition Labels is a WordPress plugin that allows you to store and display nutrition information for products. It generates memorable short URLs and QR codes that link to dedicated nutrition label pages for each product.
Features
- Product Nutrition Meta Box: Add nutrition information (ingredients, calories, kJ, carbohydrates, sugar) directly from the product editor
- Structured Ingredient List: Select individual ingredients from predefined groups (base ingredients, preservatives, acid regulators, stabilisers, gases); allergens are automatically bolded per EU Reg. 1169/2011 Annex II
- Organic Marks: Eligible ingredients can be flagged as organic origin (
*), with an automatic footnote - Short URLs: Generate memorable shortcodes (e.g.,
/l/abc12) for easy sharing - Multilingual Labels: Append a language suffix to the URL (e.g.,
/l/abc12-en) to serve the label in a different language - QR Code Generation: Download QR codes (PNG or SVG) that link directly to a product's nutrition label
- CSV Export: Export all nutrition data to a CSV file
- Database Management: Search, view, and manage nutrition entries from the admin dashboard
- Subdomain E-Label URLs: Serve nutrition labels from a dedicated subdomain (e.g.,
e-label.yourdomain.com) as recommended by EU e-labelling regulations, with automatic restriction of that subdomain to label pages only - Customizable Settings: Configure QR code size, format, and error correction level
- Clean Uninstall: Optionally delete all plugin data when the plugin is removed
Requirements
- WordPress 5.0 or higher
- PHP 8.4 or higher (required by endroid/qr-code)
- MySQL 5.6 or higher
Installation
- Upload the
nutrition-labelsfolder to the/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Go to Nutrition Labels > Configuration to adjust settings
Usage
Adding Nutrition Information to a Product
- Edit any product in your WordPress admin
- Scroll to the Nutrition Information meta box
- Fill in the nutrition fields:
- Ingredients: Select ingredients from the structured groups; choose display mode per ingredient (Text, E-number code, Organic, or None)
- Calories (kcal): Energy value in kilocalories
- Kilojoules (kJ): Energy value in kilojoules
- Carbohydrates (g): Total carbohydrate content
- Sugar (g): Sugar content
- Save the product
A short URL will be automatically generated when at least one ingredient is set.
Viewing a Product's Nutrition Label
Visit the short URL format: https://yoursite.com/[prefix]/[shortcode]
For example: https://yoursite.com/l/abc12
To request the label in a specific language, append a two-letter ISO 639-1 language code:
https://yoursite.com/l/abc12-en— Englishhttps://yoursite.com/l/abc12-de— German
If no language suffix is given, the site default locale is used. Falls back to English for unsupported languages.
Subdomain E-Label URLs (Recommended for EU Compliance)
EU e-labelling regulations advise serving digital labels from a URL that is clearly associated with the product's nutrition information — a dedicated subdomain makes the purpose immediately obvious to consumers and regulators alike.
Good subdomain choices include:
e-label.yourdomain.comnutrition-info.yourdomain.comelabel.yourdomain.comlabels.yourdomain.com
Avoid generic subdomains like www2 or opaque ones like s1 — the subdomain should communicate what the page is.
Setup
- Create a DNS record (CNAME or A) pointing your chosen subdomain to the same server as your WordPress installation.
- Add the subdomain as a server alias in your web server config (Apache
ServerAlias/ Nginxserver_name) so WordPress receives those requests. - Go to Nutrition Labels > Configuration and:
- Check Enable subdomain e-label URLs
- Enter your subdomain in the Subdomain field — either a plain label (e.g.
e-label) or a full hostname (e.g.e-label.yourdomain.com) - Select your URL scheme (
httpsstrongly recommended) - Save settings, then click Flush Rewrite Rules
From that point on, all generated short URLs and QR codes will use the subdomain:
https://e-label.yourdomain.com/l/abc12
https://e-label.yourdomain.com/l/abc12-de
Subdomain restriction
When subdomain e-label URLs are enabled, the plugin automatically restricts the configured subdomain to nutrition label pages only. Any request to that subdomain that does not match a valid short URL (e.g. someone browsing to https://e-label.yourdomain.com/) will receive a 404 response. This prevents the subdomain from accidentally exposing your full WordPress site.
Language suffixes continue to work normally on the subdomain — e-label.yourdomain.com/l/abc12-de serves the German label exactly as before.
Note: DNS propagation and web server configuration are outside the scope of the plugin. The subdomain must resolve to the same WordPress installation for short URLs to work.
Downloading QR Codes
- Edit a product with nutrition information
- In the Nutrition Information meta box, find the Nutrition Label URL field
- Click Download QR Code to save a QR code image
QR codes are generated locally on your server using the endroid/qr-code library. No data is sent to any external service.
Admin Settings
Navigate to Nutrition Labels in the WordPress admin dashboard. Changing settings requires the manage_options capability (Administrator role).
Configuration
Adjust the following settings under Nutrition Labels > Configuration:
| Setting | Description | Default |
|---|---|---|
| QR Code Size | Pixel dimensions of downloaded QR codes | 500×500 |
| QR Code Format | PNG (raster) or SVG (vector, recommended for print) | PNG |
| Error Correction | Module density vs. damage resilience trade-off | Low |
| Subdomain E-Label URLs | Serve labels from a dedicated subdomain instead of the main site | Off |
| Subdomain | The subdomain label or full hostname to use | — |
| URL Scheme | https (recommended) or http for the subdomain URLs |
https |
| Delete Data on Uninstall | Drop the database table and all records when the plugin is deleted | Off |
Warning: Enabling "Delete Data on Uninstall" is irreversible. All nutrition label records will be permanently deleted when the plugin is removed from WordPress.
The URL prefix, shortcode length, and character set are deployment constants defined in nutrition-labels.php. Advanced users can override them before the plugin loads in wp-config.php:
define('NUTRITION_LABELS_URL_PREFIX', 'n'); // changes /l/ to /n/
define('NUTRITION_LABELS_SHORTCODE_LENGTH', 6);
define('NUTRITION_LABELS_CHARACTER_SET', 'alphanumeric');
Database Management
Under Nutrition Labels > Database Management you can:
- Search nutrition entries by product name or short code
- View all nutrition data in a table
- Delete nutrition entries
- Export all data to CSV
Uninstalling
Deactivating the plugin preserves all data. To remove the plugin cleanly:
- Go to Nutrition Labels > Configuration and enable Delete Data on Uninstall
- Save the settings
- Delete the plugin from the WordPress Plugins screen
If Delete Data on Uninstall is not enabled before deletion, the database table and all nutrition records are kept in the database. Plugin options (QR settings, DB version) are always removed on uninstall.
Database Table
The plugin creates a single database table: wp_nutrition_short_urls
| Column | Type | Description |
|---|---|---|
| id | MEDIUMINT(9) | Primary key |
| product_id | BIGINT(20) | WordPress product post ID |
| url_prefix | VARCHAR(10) | URL prefix (e.g., 'l') |
| short_code | VARCHAR(10) | Unique short URL code |
| ingredients | TEXT | Ingredient list (JSON) |
| calories | MEDIUMINT(5) | Calories value |
| kilojoules | MEDIUMINT(6) | Kilojoules value |
| carbohydrates | DECIMAL(6,2) | Carbohydrates in grams |
| sugar | DECIMAL(6,2) | Sugar in grams |
| created_at | DATETIME | Record creation time |
| updated_at | DATETIME | Last update time |
User Permissions
| Action | Required Capability |
|---|---|
| Edit nutrition data on a product | edit_posts |
| Download QR codes | edit_posts |
| Access admin settings & database management | manage_options |
| Delete entries / CSV export | manage_options |
Hooks and Filters
Filter: nutrition_labels_template
Override the nutrition label template file.
add_filter('nutrition_labels_template', 'my_custom_template');
function my_custom_template() {
return '/path/to/your/custom-template.php';
}
Action: nutrition_labels_saved
Runs after nutrition data is saved for a product.
add_action('nutrition_labels_saved', 'my_callback', 10, 2);
function my_callback($product_id, $data) {
// Do something after saving
}
Frequently Asked Questions
Do I need WooCommerce to use this plugin?
No. This plugin works with any custom post type named "product". It integrates with WooCommerce products automatically if WooCommerce is installed.
How are shortcodes generated?
Shortcodes are randomly generated alphanumeric strings (A-Z, 0-9) with a configurable length (4-8 characters). The generator ensures uniqueness across all entries.
Can I change the URL prefix?
Yes, by defining the NUTRITION_LABELS_URL_PREFIX constant in wp-config.php before the plugin loads. Note: changing it will invalidate any existing printed QR codes.
Where are QR codes generated?
QR codes are generated locally on your server using the endroid/qr-code library (MIT licence). No data is sent to any external service.
Do I need a subdomain to comply with EU e-labelling regulations?
The plugin works without a subdomain. However, using a dedicated, descriptive subdomain (e.g., e-label.yourdomain.com) is recommended by EU e-labelling guidelines because it makes the purpose of the URL immediately clear to consumers. The subdomain restriction feature also ensures no other content is accidentally served from that URL.
Will my data be lost if I deactivate the plugin?
No. Deactivating the plugin does not touch the database. Data is only deleted on uninstall if you have explicitly enabled the Delete Data on Uninstall setting before deleting the plugin.
License
Copyright (c) 2026 - Markus Hammer - https://github.com/mmrtxd/
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Dependencies
- endroid/qr-code — MIT License
Support
For issues and feature requests, please open a GitHub issue.