A Safer AFFINGER5 Child Theme Workflow

An AFFINGER5 child theme gives a WordPress site a protected workspace for custom CSS, PHP functions and template changes. The parent theme can receive security patches, performance improvements and new features without wiping out the work that gives a blog its identity.

The important distinction is between settings and code. Logo choices, colours and menu assignments may live in the WordPress database, while styling rules and PHP snippets belong in theme files. Understanding where each change is stored makes updates far less stressful.

This approach suits a content site that needs to remain stable while publishing regularly. For an Australian blog targeting searches in Sydney, Melbourne or regional Queensland, a broken layout can affect enquiries, affiliate clicks and trust just as quickly as a broken checkout page.

Map every customisation before changing files

Start by making a simple inventory of the changes already made to the site. Include custom CSS, edits to functions.php, modified template files, tracking scripts, shortcodes, widgets, menus and settings in the AFFINGER5 options panel. A note in Google Docs or a version-controlled text file is enough for a small personal blog.

Separate the inventory into three groups: changes that belong in the child theme, changes controlled by WordPress, and changes better handled by a plugin. For example, typography adjustments generally belong in CSS, an affiliate disclosure should remain part of the site content or a reusable block, and analytics code is often safer in a dedicated plugin or a header-management tool.

This audit also exposes risky edits. If a parent theme file has been changed directly through the WordPress editor or hosting control panel, copy the relevant code into a local file before doing anything else. Parent theme edits are the changes most likely to disappear during an AFFINGER5 update.

Create the child theme with exact references

A child theme contains its own theme header and references the parent theme directory. The Template value must match the parent folder name exactly, including capitalisation where the server treats file names as case-sensitive. Do not guess this value: check the directory under wp-content/themes/.

A basic style.css header looks like this:

/*
Theme Name: AFFINGER5 Child
Template: affinger5
*/

The actual parent folder may differ, so replace affinger5 with the verified directory name. The child theme should be installed as a complete folder, usually uploaded as a ZIP through Appearance > Themes or placed with SFTP. Activate the child theme only after checking that the parent theme is installed and available.

Keep the child theme folder tidy from the beginning. Use clear names for assets such as custom.css, site.js and inc/affiliate-functions.php. A small site may need only style.css and functions.php, but predictable organisation helps when the blog grows or another developer needs to inspect it.

Load styles and scripts without duplication

The safest stylesheet setup is to enqueue the parent and child styles rather than relying on repeated @import statements. Enqueuing lets WordPress manage dependencies and versioning, while also reducing the chance of loading the same CSS twice.

A common pattern in the child functions.php file is:

<?php
function rico_child_assets() {
    wp_enqueue_style(
        'affinger5-parent',
        get_template_directory_uri() . '/style.css',
        array(),
        wp_get_theme( get_template() )->get( 'Version' )
    );

    wp_enqueue_style(
        'rico-child',
        get_stylesheet_directory_uri() . '/style.css',
        array( 'affinger5-parent' ),
        wp_get_theme()->get( 'Version' )
    );
}
add_action( 'wp_enqueue_scripts', 'rico_child_assets' );

Check how the installed AFFINGER5 release loads its own assets before adding this code. Some themes already enqueue the parent stylesheet, and duplicating it can create confusing cascade problems. If a child-theme starter package supplied by the theme author includes an enqueue method, follow that method rather than combining two approaches.

Place site-specific rules after the parent stylesheet and keep selectors as narrow as practical. A rule such as .entry-content .affiliate-button is easier to maintain than a broad selector affecting every button. Use browser developer tools to identify the correct class, then record why an unusual selector or !important declaration is needed.

Keep PHP changes modular and defensive

The child functions.php file is loaded alongside the parent file, not instead of it. Never copy the entire parent functions.php into the child. That creates duplicate function declarations, makes updates difficult to compare and can trigger a fatal error.

Use small functions with unique prefixes, such as rico_, to avoid collisions with AFFINGER5 or plugins. A custom excerpt filter, related-post hook or affiliate disclosure function should do one job and should be wrapped in a condition when appropriate. Check that a function or hook exists before relying on a version-specific feature:

if ( function_exists( 'add_shortcode' ) ) {
    add_shortcode( 'rico_notice', 'rico_notice_shortcode' );
}

For larger changes, place code in an inc folder and load it from the child functions.php. This keeps the main file readable. PHP syntax errors can take down the front end and dashboard, so test on staging or use a recovery method such as SFTP before activating a significant change.

Keep business logic independent from presentation where possible. An affiliate comparison shortcode should generate clean markup, while the child stylesheet controls its appearance. That separation means the same content can be redesigned for mobile visitors or a different theme without rewriting every article.

Override templates only when hooks cannot do the job

A child theme can override selected parent templates by using a file with the same name and path. This is useful when a hook cannot place content in the required location, but it is also the part of a child theme most likely to become outdated after a parent update.

Before copying a template, look for an action or filter supplied by AFFINGER5. A hook-based change usually survives structural updates more safely because the parent template remains under the theme author’s control. If a template override is necessary, add a comment at the top recording the original parent version and the reason for the override.

Review every overridden template after updating AFFINGER5. Compare the parent copy with the child copy using a file comparison tool, not by casually opening both in separate browser tabs. New accessibility attributes, schema markup, performance changes or security fixes in the parent may need to be carried into the child version.

Avoid placing essential site content solely inside a template override. A phone number, affiliate disclaimer or legal statement should be stored in WordPress content, a reusable block or a controlled options field where possible. That prevents content loss if the override is removed during a redesign.

Build an update routine that protects revenue

Before updating the parent theme, create a full backup of the database and files. A backup is useful only if it can be restored, so keep a recent copy outside the hosting account and periodically test restoration. On an Australian site, also check that the backup includes locally important configuration such as email delivery, caching and payment settings.

Use a staging copy to install the AFFINGER5 update first. Test the home page, category archives, individual posts, contact form, search, menus, responsive layouts and any affiliate comparison tables. Check pages at common mobile widths, since many readers on Australian NBN or mobile connections will still browse on a phone while commuting or travelling.

After the live update, clear WordPress, server and CDN caches, then inspect the site in an incognito window. Confirm that Australian product prices display in AUD where relevant, affiliate links retain their tracking parameters, and disclosures remain visible. If the site targets local searches such as “physio jobs Brisbane” or “WordPress consultant Perth”, review those landing pages rather than testing only the home page.

A practical child-theme routine includes these safeguards:

For affiliate marketing, clear commercial disclosures matter as much as visual stability. The Australian Competition and Consumer Commission expects advertising relationships to be presented clearly, and readers should not have to hunt through a footer to understand that a link may earn commission. Place the disclosure near relevant recommendations and keep its wording consistent across posts.

The finished child theme should be deliberately boring: custom code is easy to locate, templates are overridden only when necessary, and every change has a reason. With that structure, an AFFINGER5 update becomes a controlled maintenance task rather than a gamble with the site’s design, search visibility and income.