How AFFINGER5 custom post meta can keep affiliate badges tidy
Affiliate badges are handy for a product round-up or travel guide, but pasting a bright image into the article body can interrupt reading and make the page harder to update. AFFINGER5 custom post meta gives each badge its own data fields, so the link, image and wording live outside the main copy. You can then place them in a controlled section of the single-post layout rather than scattering tracking links through every paragraph.
On ricoblog, I prefer a workflow that separates content from monetisation. The same post can then use a new badge image or retailer URL without touching its layout, while the affiliate disclosure stays visible and the page remains fast on mobile. The method below works with the theme’s editing options and, where needed, a small child-theme snippet rather than direct edits to a parent template.
Why badge data belongs in custom post meta
Putting a badge in the body forces every edit to depend on the current paragraph structure. Move an image, add another sponsor or change a destination and the content can break. It also makes visual consistency difficult when one review uses a small banner and the next uses a full-width graphic.
Custom post meta stores each badge as structured data: the destination, asset, label and optional retailer. The article remains readable, while AFFINGER5 controls where and how the badge appears. A global styling change can update every badge without hunting through old posts.
That separation also protects affiliate URLs from accidental edits. Tracking parameters stay intact, labels can be reused consistently, and an expired offer can be disabled without revising the surrounding review. It is a cleaner model for a growing library of Australian gear, software and travel posts.
Setting up the fields in AFFINGER5
Open a single post in WordPress and look for AFFINGER5’s custom meta or post options panel. Field names can differ slightly between theme releases, but the useful set is small. Create fields for the badge image, tracking URL, link label and retailer or network name. Keep the names consistent because the display template will look for those exact keys.
For the image, store a Media Library attachment ID where the theme allows it; it survives changes to a file name better than a pasted URL. A plain image URL is an acceptable fallback. Add a second set with a numeric suffix only when a post needs two genuinely different offers, such as a hosting plan and a domain registrar.
Do not create fields for live prices, stock levels or discount claims. Affiliate feeds are often delayed, and a stale figure in metadata can mislead readers. Store the destination and let the retailer show its current price. If your build does not expose a ready-made custom-fields panel, register equivalent fields through a child theme or small plugin rather than editing parent files.
Choosing badge content that stays compact
Choose a badge that answers one question without competing with the article. A simple “Check price” or “See details” label works for most posts. Keep the graphic around a 2:1 ratio, compress it without smearing the logo, and make the alt text describe the destination instead of repeating a keyword list.
Australian readers tend to appreciate plain, low-pressure wording. Phrases such as “fair enough” may suit a personal travel post, while a technical buying guide calls for something more direct. “Check the current price” feels natural in Australia and avoids implying that clicking the badge is itself a purchase. The label should also work when the image fails to load.
Keep badge text free of claims such as “cheapest” or “best value” unless you can substantiate them. Use the same visual family across posts, but let the destination URL and label change by offer. This creates a predictable affiliate section that visitors learn to recognise.
Displaying badges without breaking the theme
If AFFINGER5 offers a meta-output area for single posts, map the badge fields to that slot and leave the post body free of the graphic. Check the option that controls its position, such as before or after the article. If the theme cannot render the fields, use a child theme so the change survives an update. Never place custom code directly in the parent theme’s functions.php.
Here is a minimal filter for a child theme. It appends one badge to the main single-post content, skips archives and related posts, and outputs safe URLs. Replace the example field names with the keys created in AFFINGER5.
function ricoblog_affinger5_badge($content) {
if (!is_singular() || !in_the_loop() || !is_main_query()) {
return $content;
}
$post_id = get_the_ID();
$url = get_post_meta($post_id, 'ricoblog_badge_url', true);
$image = get_post_meta($post_id, 'ricoblog_badge_image_url', true);
$label = get_post_meta($post_id, 'ricoblog_badge_label', true);
if (!$url || !$image) {
return $content;
}
$label = $label ? $label : 'Affiliate link';
return $content . sprintf(
'<div class="ricoblog-affiliate-badge"><a href="%1$s" target="_blank" rel="sponsored noopener"><img src="%2$s" alt="%3$s"></a></div>',
esc_url($url),
esc_url($image),
esc_attr($label)
);
}
add_filter('the_content', 'ricoblog_affinger5_badge');
The callback adds no heading or border by itself, which keeps the page visually quiet. Add a compact style in the child theme, centre the image, cap its width and allow it to shrink on narrow screens. If the badge belongs near the first recommendation rather than the end, use an AFFINGER5 content hook or place a shortcode block instead of appending it to all content.
Keeping the approach Australian and compliant
Australian affiliate links need more care than a generic “shop now” button. A reader in Melbourne, Brisbane or Perth should reach an Australian version of the offer with AUD pricing, local delivery information and familiar returns. Amazon.com.au, Awin, Impact and CJ can supply suitable campaigns, but the final landing page matters more than the network name.
Prices advertised to Australian consumers are generally expected to include taxes and charges, so a badge should not rely on an overseas price shown without GST. Local warranty, shipping and customer-service details can also change the value of a deal. Use current figures from the retailer’s Australian page, and send readers there rather than trying to reproduce the whole offer in a small graphic.
Clear disclosure is part of the design, not legal text buried after the comments. The Australian Competition and Consumer Commission treats a material connection, including a commission from an affiliate link, as something that should be disclosed clearly. Put a sentence near the first affiliate link stating that the post contains affiliate links and the author may earn a commission. The rel="sponsored" attribute helps, but it does not replace visible wording.
If the badge or its destination collects analytics, review cookie consent and the Australian Privacy Principles before collecting personal information. This is especially relevant when a campaign adds a reader to an email list. The badge itself can remain simple as long as the tracking and disclosure are handled openly.
Testing and maintaining the system
Before relying on the workflow, open a published post in a private window and follow the badge as a logged-out visitor. Test the destination on desktop and mobile, inspect the keyboard focus, and check that the image does not push the article sideways. Clear the page cache after changing the PHP filter so the new markup appears immediately.
Each badge only needs a small, dependable set of values:
- The complete affiliate destination URL, including its tracking parameters
- The image URL or Media Library attachment ID
- A short link label that also works as alternative text
- The retailer or network name for reporting and future replacements
Use a consistent check before the post goes live:
- The link opens the intended Australian landing page and records the correct click
- The badge remains readable at narrow mobile widths and passes keyboard navigation
- Any price, discount, availability and delivery claim is current
- The affiliate disclosure appears before or beside the first monetised link
- The layout still looks tidy with the image blocked or missing
Keep a small record of campaign names and renewal dates in the post meta or your own tracking sheet. When a retailer changes its programme, update the destination and retest the affected posts. Periodic link checks are useful, but the real benefit comes from treating the badge as reusable site data rather than decoration pasted into an old article.