WordPress.org

Support

Support » Alpha/Beta » Codex Regarding Child Theme Function Redeclaration?

Codex Regarding Child Theme Function Redeclaration?

  • Inn the codex, where it explains the new features of WP 3, it says:

    TIP FOR THEME DEVELOPERS. The fact that a child theme’s functions.php is loaded first means that you can make the user functions of your theme pluggable—that is, replaceable by a child theme—by declaring them conditionally. E.g.:

    if (!function_exists('theme_special_nav')) {
        function theme_special_nav() {
            //  Do something.
        }
    }

    However, whenever I try to redeclare a function in a child theme functions.php that is already decalred in the parent theme, I get a fatal error ‘Cannot redeclare….etc’.

    This happens whether or not I wrap the redeclared function in
    if (!function_exists

    or not.

    Is the Codex wrong?
    Should I report this as a bug for WP 3?
    Or have I misunderstood?

    I am running WP 3 Beta 2.

    Many thanks.

  • The topic ‘Codex Regarding Child Theme Function Redeclaration?’ is closed to new replies.
Skip to toolbar