[Resolved] Child theme javascript and include files

Home Forums Support Child theme javascript and include files

  • This topic has 3 replies, 2 voices, and was last updated 5 years ago by Tom.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #156905
    Sally

    Hello,

    We have created Generate Press child theme. Included in this theme is a js and inc folder for functionality. The inc folder hosts a customised template tags php file. However, this doesn’t flow through to the theme. Instead the customised template tags file has to be included in the parent theme, which gets over-written on theme update. How should we handle this type of customisation?

    #156907
    Tom
    Lead Developer
    Lead Developer

    Hi Sally,

    Instead of doing it that way (and potentially missing out on anything I add to the template-tags.php file in the future), look for the functions you want to alter.

    If they’re wrapped in a function_exists tag like this:

    if ( ! function_exists( 'function_name' ) ) :
    function function_name()
    {
    
    }
    endif;

    It means I’ve made it so you can overwrite that function.

    Simply copy the function (and ! function_exists tag) into your functions.php file and make your changes, and it will overwrite the theme’s function.

    Hope this helps 🙂

    #157186
    Sally

    Hi Tom,

    Thanks for this! Will give it a go. Awesome theme. Really looking forward to our in-house launch. 🙂

    #157193
    Tom
    Lead Developer
    Lead Developer

    No problem! Glad you’re enjoying it 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.