Child Theme Redeclared Functions do not behave as Codex says (3 posts)

  1. cognitions
    Posted 5 years ago #

    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.

  2. 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.

  3. cognitions
    Posted 5 years ago #

    That would make sense. I'll test that.
    Many thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic