Support » Alpha/Beta/RC » Child Theme Redeclared Functions do not behave as Codex says

  • Sorry for double post. Only just discovered this forum:
    In 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 declared 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Les Bessant

    (@lesbessant)

    keeper of the Tiggers

    If I’m reading your question correctly, I think you have misunderstood.

    It’s the function in the parent theme that needs the conditional declaration, not the one in your child theme.

    Ah.
    That would make sense. I’ll test that.
    Many thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Child Theme Redeclared Functions do not behave as Codex says’ is closed to new replies.