Override theme-functions.php

  • Author
    Posts
  • #4354
    Paul Harrison

    Hi,

    I want to change some text in the theme-functions.php file on the main mantra theme, so have created a child theme which all works well however this file won’t override so no matter what changes I make to the child theme theme-function.php file it wont display.

    I have put it in mantra-child->includes so it is in the same position as the main theme but it doesn’t work.

    Can anyone advise?

    Thanks

    #4372
    Zed
    Cryout Creations mastermind

    Some functions are automatically replaced if you use the same function name in the child theme, bust most core functions are a bit more difficult to override.

    You need to individually un-hook Mantra actions and hook your own modified child theme functions in their place.

    Example:


    // remove mantra functions action hooks
    function remove_mantra_functions() {
    remove_action('cryout_existing_hook', 'mantra_existing_function',[priority-if-set]);
    }
    add_action('init','remove_mantra_functions');
    // custom child function
    function child_theme_function_replacement() {
    ... }
    // add replacement child function
    add_action('cryout_existing_hook','child_theme_function-replacement',[same-priority-as-replaced-function-if-set]);


    If you like our creations, help us share by rating them on WordPress.org.
    Please check the available documentation and search the forums before starting a topic.
    #4407
    Paul Harrison

    Hi,

    Is this done in the child version of the main template version of the file?

     

    #4565
    Zed
    Cryout Creations mastermind

    This is done in the child theme’s functions.php file.


    If you like our creations, help us share by rating them on WordPress.org.
    Please check the available documentation and search the forums before starting a topic.
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Override theme-functions.php’ is closed to new replies.