Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #622691

    So I want to override a bunch of Enfold’s functions, and I’m wondering if it’s possible to do this all in the child theme’s functions.php instead of having to modify Enfold’s php files. For example, if I want to change avia_set_title_tag() in function-set-avia-frontend.php:

    if(!function_exists('avia_set_title_tag'))
    {
        /**
         * generates the html page title
         * @return string the html page title
         */
        function avia_set_title_tag()
        {
            $title = get_bloginfo('name').' | ';
            $title .= (is_front_page()) ? get_bloginfo('description') : wp_title('', false);
    
            $title = apply_filters('avf_title_tag', $title, wp_title('', false));
    
            return $title;
        }
    }

    Since the function is declared inside of if(!function_exists('avia_set_title_tag')) am I correct in assuming that I can just write this in functions.php to override it?

    function avia_set_title_tag()
    {
        $title = wp_title('', false);
        $title = apply_filters('avf_title_tag', $title, wp_title('', false));
        return $title;
    }
    • This topic was modified 7 years, 11 months ago by morecolor.
    #622771

    Hi morecolor!

    Thanks for getting in touch with us!

    You are absolutely right. The part of the code if(!function_exists(‘avia_set_title_tag’)) checks to see if the function exists in the child theme’s functions.php file before executing the parent theme’s function. So you simply need to use the same function name in the child theme to override the function.

    Let me know if you need further assistance.

    Cheers!
    Jordan

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