WordPress.org

Support

Support » How-To and Troubleshooting » Question about functions.php

Question about functions.php

  • Accoding to the codex this loads before any file (correct me if I am wrong), so How is it that frameworks are able to create a custom-functions.php and those functions in there are run, before the rest of the theme?

    Example,

    Lets say in my theme framework I have some pluggable function

    if(!function_exists('function_name')){
        function function_name(){}
    }

    If in my functions, or custom-functions.php I define that method function_name(){} every thing works out and is happy.

    How ever if in my functions or custom-functions.php I say:

    require_once(‘path_to_file.php’) where path_to_file contains the definition of that method function_name() I get an error. Saying it was already defined in such and such file on such and such line.

    Yes I can define it in the functions.php or custom-functions with no error? I just cannot link to a file, in the functions or custom-functions that defines it?

    why? if the case is, that the functions.php or custom-functions.php runs before any theme file then the fact that I am linking to a file that redefines the method should not be an issue.

    thoughts?

  • The topic ‘Question about functions.php’ is closed to new replies.