Build an AFFINGER5 child theme without losing affiliate settings
AFFINGER5 gives bloggers a polished, affiliate-focused design, but editing its parent theme files creates two connected risks. A WordPress parent theme update can replace those files, while switching the active stylesheet can change where Customizer values and theme-specific options are read. A child theme separates your custom code from the parent and gives your work a stable home without changing the design you already use.
The affiliate configuration itself usually lives in the database rather than in style.css, including ad placements, banner settings, shortcode outputs and tracking details. Preserving it requires more than copying a template: you need a recoverable backup, a controlled settings migration and link-by-link testing. The workflow below is designed for an Australian blog, where local affiliate programs, consumer expectations and privacy duties make careful verification especially valuable.
Back up the live site and create a staging copy
Start with recoverable copies of both the database and the wp-content folder, including uploads, themes and relevant server configuration. Use your hosting provider’s backup tool and a second export such as UpdraftPlus, then confirm that the archives open and contain the expected files. A database-only backup will not protect custom theme files, while a file-only backup leaves affiliate settings exposed. Record the installed parent theme version as part of the backup notes.
Create a private staging clone, preferably on a temporary domain or a separate local environment. Search-replace the production URL so cached assets and internal links do not point back to the live site, and disable indexing and caching on the clone. This gives you a place to activate the child theme without affecting visitors, search crawlers or live advertising campaigns. Protect the staging URL with authentication and share it only with people who need it.
Before changing anything, open the AFFINGER5 theme options and WordPress Customizer. Export the panel data if the installed version offers an export function; otherwise take labelled screenshots of every affiliate section. List each campaign URL, affiliate or partner ID, coupon field where used, ad block, banner, social profile and analytics property. Also note assigned menus, widgets and the custom logo. This inventory becomes the comparison sheet for the migration.
Create the child theme with the correct parent reference
Confirm the parent theme’s exact directory slug rather than assuming that the product name is the value WordPress expects. Open Appearance > Themes, inspect the installed parent, and check its stylesheet header and server folder. The Template value must match that slug exactly, including case. If the folder is named differently, replace the example below before uploading anything.
Create a folder named ricoblog-affinger5-child inside wp-content/themes. Add a style.css file containing the required parent pointer:
/*
Theme Name: ricoBlog AFFINGER5 Child
Description: Customisations for the ricoBlog AFFINGER5 site.
Author: Rico
Template: affinger5
Version: 1.0.0
Text Domain: ricoblog-affinger5-child
*/
Create functions.php in the same folder. The parent remains the template and loads its own assets, so the child file only needs your overrides:
<?php
defined( 'ABSPATH' ) || exit;
add_action(
'wp_enqueue_scripts',
function () {
wp_enqueue_style(
'ricoblog-affinger5-child',
get_stylesheet_uri(),
array(),
filemtime( get_stylesheet_directory() . '/style.css' )
);
},
99
);
The late priority registers the child stylesheet after the usual parent styles. Check the rendered page source for duplicate child CSS; if the parent already enqueues the child file automatically, remove the redundant loader. Zip the folder and upload the ZIP through Appearance > Themes > Add New > Upload Theme, or transfer it over SFTP. Install it but leave it inactive until the settings helper is ready. A WordPress preview can reveal layout issues, but staging activation is the reliable test because it reproduces the admin and database context.
Move the AFFINGER5 settings into the child
WordPress stores many theme values in wp_options. Values registered through get_theme_mod() are grouped under a stylesheet-specific key such as theme_mods_affinger5, so menu locations, the custom logo and some Customizer choices can appear blank after a stylesheet switch. Standard options and many AFFINGER5 panel values are shared and should remain in place. Because each release can organise these values differently, treat activation as a settings event rather than a cosmetic change.
Add this temporary helper to the child functions.php before activation. It copies the parent’s theme modifications into the child’s namespace while giving any existing child values priority:
function ricoblog_affinger5_copy_parent_mods() {
$parent_key = 'theme_mods_' . get_template();
$child_key = 'theme_mods_' . get_stylesheet();
$parent_mods = get_option( $parent_key, array() );
$child_mods = get_option( $child_key, array() );
if ( ! is_array( $parent_mods ) || empty( $parent_mods ) ) {
return;
}
if ( ! is_array( $child_mods ) ) {
$child_mods = array();
}
update_option( $child_key, array_merge( $parent_mods, $child_mods ) );
}
add_action( 'after_switch_theme', 'ricoblog_affinger5_copy_parent_mods', 20 );
Most theme-panel values stored under a fixed option name remain available automatically because the option itself is not renamed. On staging, WP-CLI can reveal likely keys without editing the database by hand:
wp option list --search=affinger --fields=option_name,autoload
wp option list --search=theme_mods_ --fields=option_name,autoload
Use the results with the parent theme code and your settings inventory to identify the source. Export a known record for comparison with wp option get ACTUAL_OPTION_NAME --format=json, replacing the placeholder with the real key. If a value is tied to the old stylesheet, copy only that verified record; do not bulk-copy every option that happens to contain “affinger”.
Activate the child on staging and let the hook run. Compare the Customizer, AFFINGER5 panel, menus, widgets and ad placements against the inventory, then re-enter only values that did not migrate. If the parent theme hides its monetisation panel when a child is active, keep the affiliate values in the database and contact the theme developer for the supported access method. Once the transfer is verified, remove the one-time helper and keep a copy in your deployment notes, preventing a later theme switch from silently changing the child configuration.
Keep customisations isolated and test affiliate links
Put layout changes in style.css and behavioural changes in functions.php. To alter a template, copy only the relevant parent file into the child under the same path and edit that copy. Avoid copying an entire template by default, because it severs the parent theme’s future fixes. Keep affiliate IDs, campaign destinations and banner content in the theme panel or another database-backed settings source rather than hard-coding them into templates. This separation makes the child portable and prevents code edits from drifting away from the monetisation configuration.
Test the staged site in a logged-out browser and an incognito window. Open every affiliate link type, including post, button, banner, coupon and related-product placements. Confirm that the destination, partner ID, sub-ID and any UTM parameters match the live site, and that no link creates a redirect loop. Check that each advertisement appears once, the page has no broken placeholders, and analytics or consent tools do not fire twice. Repeat the checks on a post, archive, category, author and mobile layout because template variations can expose errors hidden on the home page.
For Australian traffic, verify that intended campaigns land on suitable local offers, often on .com.au domains or established Australian retailers such as Amazon.com.au or eBay Australia. Check that displayed prices are in Australian dollars, GST treatment and shipping terms are clear, and the link works on a mobile connection. Affiliate relationships should also be disclosed plainly near commercial links in line with ACCC guidance and the Australian Consumer Law; vague statements buried in the footer are poor practice and can undermine reader trust.
Roll out safely and maintain the child theme
After staging passes, back up the live site again, schedule a short maintenance window and activate the child theme. Keep the parent theme installed because the child depends on it. Watch the home page, a monetised article, forms, search and the WordPress admin immediately after activation. Update the parent only after the child is active, then repeat the link and ad checks; a new parent release can change markup or hooks even when the child code is untouched.
Keep the child folder under version control, excluding credentials and exported personal data. Give the child a meaningful version, note which AFFINGER5 release it was tested against, and document every override with its reason. Scheduled file-and-database backups, a monthly affiliate-link test and periodic reviews of live ad placements provide a simple maintenance rhythm. When the child CSS changes, its file timestamp busts the browser cache; clear the WordPress or CDN cache as well when styles still appear stale.
Operational details matter for an Australian publisher. Sydney and Melbourne observe AEDT in summer and AEST in winter, while Brisbane remains on AEST, so schedule campaign launches with those differences in mind. Budget for fees in Australian dollars, check whether GST applies to overseas plugins or hosting subscriptions, and retain the invoices; registered businesses may be able to claim eligible input tax credits. Keep affiliate income records for the Australian Taxation Office, including ABN details and GST treatment where the business is registered. Also confirm that analytics, advertising cookies and vendor data flows meet the Privacy Act 1988 and applicable consent expectations. With a tested child theme and a dated settings inventory, each parent update can be handled without losing the affiliate configuration that earns from the audience.