• I would like to customise the template-tags.php file. I have made the necessary changes, which work as required, but when I export the file into a child theme (and restore template-tags.php in the Kumle parent), the changes don’t come into effect.

    As well as pacing /includes/template-tags.php in my Child theme, I have also created /includes/main, which contains “require_once trailingslashit( get_template_directory() ) . ‘/includes/template-tags.php’;”.

    What else is required in order to get my amended template-tags to operate?

    Many thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @scarne

    get_template_directory() will load file from parent theme. As you are creating child theme you need to use get_stylesheet_directory(). So your final code will be like
    require_once trailingslashit( get_stylesheet_directory() ) . '/includes/template-tags.php’';
    Hope this will solve your issue.

    Thread Starter Simon Carne

    (@scarne)

    Many thanks, @maneshtimilsina.

    It took me a while to realise that I also need to add a similar line to the child theme functions.php in order to load the amended main file, ie
    require_once trailingslashit( get_stylesheet_directory() ) . ‘/includes/main.php’;

    Once I had done that, all was working just fine. Many thanks for respponding so quickly.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Customising template-tags.php in a child theme’ is closed to new replies.