How can override function of the parent theme ?

  • Mathieu
    Mathieu
    Newbie 8 points
    July 23, 2016 at 10:14 pm

    Hello,

    after have trying 2 hours anything for override the functions of the parent theme, i need your help.

    I need override the functions of framework core :

    function packageenhancements() – line 3642 – class_core.php

    function wlt_shortcode_image() – line 285 – class_media.php

    Thanks you in advance, if you need more information, not hesitate 🙂


  • Josh
    Super Guru 13,875 points
    July 25, 2016 at 2:17 pm

    Hello Mathieu,
    Use hooks and filters
    More info >>

    Docs


    There are also so many articles online on Hooks and filters

  • Mathieu
    Mathieu
    Newbie 8 points
    July 25, 2016 at 8:30 pm

    Hello,

    i m sorry but only not working, i can override hook design layout but not the functions from the core framework.

    if exemple i want use the remove_action, exemple :

    remove_action( ‘ ????????? ‘, ‘wlt_shortcode_image’);

    init, after_setup_theme, not working, why ?

    Thanks

  • Mathieu
    Mathieu
    Newbie 8 points
    July 27, 2016 at 5:20 am

    Hello,

    no have solution for use the normal hook from wordpress ?

    Cordially

  • Aaron
    Aaron
    Super Guru 920 points
    July 27, 2016 at 6:17 am
    <?php
    if ( ! function_exists ( 'my_function' ) ) {
        function my_function() {
            // Contents of your function here.
        }
    }
    ?>

    Good link with explanations: https://code.tutsplus.com/tutorials/a-guide-to-overriding-parent-theme-functions-in-your-child-theme–cms-22623

  • Mathieu
    Mathieu
    Newbie 8 points
    July 27, 2016 at 6:23 am

    Hello,

    thanks you for your awser.

    How can override action with priority when you not declare your action with add_action ?

    can you give me an true exemple please.

    Thanks you.

  • Aaron
    Aaron
    Super Guru 920 points
    July 27, 2016 at 9:14 am

    It tells you in that article.

  • Mathieu
    Mathieu
    Newbie 8 points
    July 27, 2016 at 9:23 am

    not working,

    exemple in my functions.php

    if ( ! function_exists ( ‘packageenhancements’ ) ) {
    function packageenhancements() {
    echo “content package”;
    }
    }

    why not automatical override the function ?

  • Mathieu
    Mathieu
    Newbie 8 points
    July 28, 2016 at 1:18 pm

    Hello,

    i need only one exemple for understand.

    can you help me ?

    put here one exemple please.

    Thanks you

  • Mathieu
    Mathieu
    Newbie 8 points
    July 29, 2016 at 2:14 pm

    Hello,

    solution for me ?

  • Aaron
    Aaron
    Super Guru 920 points
    July 30, 2016 at 1:01 am

    You need to create a child theme and place the code in your own functions.php file.

    https://codex.wordpress.org/Child_Themes

  • Mathieu
    Mathieu
    Newbie 8 points
    August 3, 2016 at 6:56 am

    thanks you so much for no have solution ….

    good support, just awser for change the way ….

    @ +


  • David
    Newbie 21 points
    August 31, 2016 at 5:03 pm

    Aaron, you are a great guru, thank for the links.

  • Alex Morgan
    Alex Morgan
    Super Guru 1,111 points
    September 2, 2016 at 2:47 pm

    Thanks for sharing Aaron 🙂

Viewing 14 posts - 1 through 14 (of 14 total)

New Business Themes for WordPress 2020

Start your new website today!

View Business Themes