I have two sets of custom font icons that from my understanding are being loaded by two php files of the theme that i am making a child theme of : admin-style.php & icons.php

admin-style.php :

$admin_style = sanitize_text_field('

    src:url("' . get_template_directory_uri() . '/fonts/Stefanos/Stefanos.woff") format("woff"),url("' . get_template_directory_uri() . '/fonts/Stefanos/Stefanos.ttf") format("truetype");
    font-family: Stefanos;
    font-family: Stefanos;
}', array() );

icons.php :

$icons = sanitize_text_field('

@font-face {
        font-family: "Stefanos";
        src: url("' . get_template_directory_uri() . '/fonts/Stefanos/Stefanos.woff") format("woff"), url("' . get_template_directory_uri() . '/fonts/Stefanos/Stefanos.ttf") format("truetype");
*[data-ico-stefanos]:before {
        font-family: Stefanos;
        content: attr(data-ico-stefanos);
}', array() );

What is happening is that

• when i move those two files containing the custom font icons loading code, to the child theme, the icons are not being loaded. The icons code works only when those two php files are in the parent theme. Even in the form of get_parent_theme_file_uri instead of get_template_directory_uri it works only when is in the parent theme.

• When moving the admin-style.php & icons.php to the child theme, and keeping the font files folder (/fonts/Stefanos) in the parent theme, the custom icons are not being loaded

• When moving the admin-style.php & icons.php and the font files folder (/fonts/Stefanos) to the child theme, the custom icons are not being loaded.

• Using get_stylesheet_directory_uri instead of get_template_directory_uri it doesnt work either, no matter where the php and the font files are, in the parent or the child theme

What's keeping the custom font icons from loading when placed in the child theme?

  • You can't just copy arbitrary files into a child to replace them. That's not how it works. If you copy admin-style.php to the child theme nothing is going to happen if the parent theme is including it from the parent theme. What to do instead depends on how and where these files are being used by the parent theme. You may need to unhook them from a hook and then use the child theme to hook the child theme versions back in, but it's not possible to say based on the code provided. Commented Feb 25 at 7:47
  • I appreciate the info. If there are related hooks, the only place to be found are in the parent theme's functions.php, right ? Commented Feb 25 at 16:16
  • Yes, but functions.php can also include or require other PHP files, so the relevant code could also be in those. Commented Feb 26 at 5:40
  • Here are the parent theme files i could spot that appear to control the loading of icons, just in case someone is interested to take a look. drive.google.com/drive/folders/… Commented Feb 26 at 18:31


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.