WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Changes to functions.php

[Resolved] Changes to functions.php

  • Is there a way to make changes to the functions.php file so that when my theme is updated I won’t need to make the changes again?

    I require a piece of code to be removed from the (parent/original) functions.php file. Using a functions.php file in a child theme is great for adding new functions but not removing existing ones.

    Any ideas?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Unfortunately, no. But, you could ask the theme author to make their functions “pluggable”. Basically, they would wrap their functions in an if statement, like:

    if( ! function_exists('some_theme_function') ) {
        function some_theme_function() {
            // function code
        }
    }

    That way, you could create a function some_theme_function in your child theme, overriding the parent’s function.

    In the mean time, just comment out each parent function that you recreate in your child theme, and remember to re-comment them out each upgrade.

    Great thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Changes to functions.php’ is closed to new replies.