Ready to get started?Download WordPress


Mantra Child Theme and modified theme-functions.php (8 posts)

  1. lg77
    Posted 1 year ago #

    How can I use the modified theme-functions.php in the mantra child theme? I placed functions.php:

    require_once(dirname(__FILE__).”/theme-functions.php”); //Theme misc functions

    and modified theme-functions.php into the child’s root folder to no avail.

    But this new theme-functions.php works correctly in the mantra parent theme.

    May be it requires placing some other files in the child directory or it is not possible to make it work at all, I do not know.

    Any thoughts?

    Thank you in advance.

  2. paulwpxp
    Font hero
    Posted 1 year ago #

    That's now how you override function in child theme.

    Please review this part in the doc here

  3. lg77
    Posted 1 year ago #

    Thank you, paulwpxp!

  4. lg77
    Posted 1 year ago #

    http://codex.wordpress.org/Child_Themes#Using_functions.php just proves to me that what I was going to change in some mantra function (part of the theme-functions.php) is not possible to do without losing changes after parent update.
    It doesn't use "if ( ! function_exists ...", so it is not possible to make it "...pluggable —that is, replaceable by a child theme— by declaring them conditionally...".
    I have tried to add the modified function to the functions.php in the child theme and used "if ( ! function_exists ..." in the parent theme-functions.php and it worked for me. The original parent function was replaced by the child function. But I realize that it will stop working after the parent upgrade.

  5. paulwpxp
    Font hero
    Posted 1 year ago #

    Typo "That's now how.." should be "That's not how.."

  6. paulwpxp
    Font hero
    Posted 1 year ago #

    The theme breaks its functions into sections and require each file.

    Some of the functions are pluggable

    For one that's not pluggable, you could still use remove action and add your own version of that function.

  7. lg77
    Posted 1 year ago #


    Thank you for your prompt response. I successfully used remote-action to make my function pluggable. I found this link: http://venutip.com/content/right-way-override-theme-functions and it was a real time saver.

  8. lg77
    Posted 1 year ago #

    typo "remote-action" correct is "remove_action"

Topic Closed

This topic has been closed to new replies.

About this Topic