• Resolved little_bird

    (@little_bird)


    Hi

    I’ve been trying for hours to use the function twentyseventeen_get_svg in the file functions.php of my child theme. For some reason I get a fatal error “Call to undefined function” but when I use twentyseventeen_get_svg in files like header.php I don’t get any error.

    Please, what should I do to use twentyseventeen_get_svg in my functions.php?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    The way the theme knows about this function is by including the file it is defined in:

    
    
    /**
     * SVG icons functions and filters.
     */
    require get_parent_theme_file_path( '/inc/icon-functions.php' );
    

    So you might need to do the same.

    functions.php of the child theme gets executed before the functions.php of the parent theme; therefore, twentyseventeen_get_svg is not defined yet when you try to use it.

    depending on your intended code, try to work with:

    add_action( 'after_setup_theme', 'whatever_you_want_to_do' );
    
    function whatever_you_want_to_do() {
    
    		//including//
    		twentyseventeen_get_svg();
    
    }
    Thread Starter little_bird

    (@little_bird)

    Hi Andrew

    Thanks for your answer. Yes, in the file functions.php of the parent theme the icon-functions.php file is included, so I supposed to use the twentyseventeen_get_svg in my functions.php child theme, but I keep getting “Fatal Error: Call to undefined function ….”.
    So I tried to copy the twentyseventeen_get_svg function in my functions file but then I got the message ” Cannot redeclare twentyseventeen_get_svg()…” since is not a pluggable function.

    How can I use that and other functions of the Twenty Seventeen theme in my functions.php?

    Thanks

    Thread Starter little_bird

    (@little_bird)

    Hi Michael

    That works!!! You are right. You saved my life ??

    Thanks a lot

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘child theme’ is closed to new replies.