Back to Community

Why Can't I Copy template-tags.php? Understanding Template Files vs. Functions

8 threads Sep 10, 2025 PluginChild theme configurator

Content

Many users of the Child Theme Configurator plugin run into a common roadblock: they want to edit a specific piece of code, like the footer copyright text, but the file they need (often template-tags.php or similar) is not available to copy in the plugin's Files tab. This article explains why this happens and what you should do instead.

The Problem: Missing Files in the 'Parent Templates' List

You've set up your child theme, navigated to Tools > Child Themes > Files, and are ready to copy a file from the parent theme. But the specific file you're looking for, such as inc/template-tags.php, is not listed under Parent Templates. This can be confusing if you know the file exists and contains the code you want to change.

Why This Happens: Templates vs. Function Libraries

The Child Theme Configurator is designed to only list template files (like header.php, footer.php, page.php) that are safe to copy. It intentionally hides other types of PHP files. As seen in the sample threads, the plugin's official response is:

"If a PHP file is not available as an option to copy then it contains functions or classes. These files are not templates, but rather 'includes,' and copying them could create fatal duplicate function or class errors."

Files like template-tags.php, functions.php, or other files in an /inc/ folder are typically function libraries. They are loaded by the parent theme to define reusable blocks of code. Copying such a file to your child theme would cause WordPress to load it in addition to the parent's version. Since both files would try to define functions with the same name, it would trigger a fatal PHP error and break your site.

The Solution: How to Safely Modify the Code

You cannot directly copy the entire function library file. Instead, you must use a different, safer method to override the specific function you want to change.

Method 1: Modify the Correct Template File

Often, the code you want to change is output by a function but is actually called from within a template file you can copy.

  1. In the Child Theme Configurator's Files tab, find and copy the appropriate template file. For footer copyright text, this is most likely footer.php.
  2. Edit the new footer.php file in your child theme. Look for the line that calls the function (e.g., onepress_footer_site_info();).
  3. You can replace this function call with your own hard-coded HTML or text.

Method 2: Re-declare the Function in Your Child Theme's functions.php

This is the more technically correct method for overriding a function from a parent theme.

  1. Do not copy the entire template-tags.php file.
  2. Instead, open your child theme's functions.php file for editing (you can use the Child Theme Configurator's File Editor or a text editor).
  3. Copy the entire original function from the parent theme's file and paste it into your child theme's functions.php.
  4. Crucially, you must remove the if ( ! function_exists( ... ) ) { condition that wraps the function. This condition is what prevents the fatal error. The parent theme checks if the function already exists before defining it. By defining it first in your child theme, you ensure your version is used.
  5. Now, modify the code inside your copied function to make your desired changes (e.g., change the copyright text).

For example, your child theme's functions.php would look like this:

function onepress_footer_site_info() {
    ?>
    <?php printf(esc_html__('Copyright %1$s %2$s %3$s', 'onepress'), '©', esc_attr(date('Y')), esc_attr(get_bloginfo())); ?>
    <span class="sep"> – </span>
    <?php printf(esc_html__('%1$s theme by %2$s', 'onepress'), 'Your Custom Text Here', 'Your Name'); ?>
    <?php
}
add_action( 'onepress_footer_site_info', 'onepress_footer_site_info' );

Conclusion

The Child Theme Configurator wisely prevents you from copying files that would cause fatal errors. When you can't find a file in the list, it's a sign that you need to use a different approach—either editing a related template file or re-declaring a function in your functions.php. Following these methods will allow you to safely customize your theme without breaking your website.