Home Forums Theme Support Dokan Overriding the functions.php parent file in a child theme

This topic is: resolved

This topic contains 7 replies, has 3 voices, and was last updated by  Nayem 4 years, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #31718

    Hovsep
    Member
    Post count: 7

    Hi,
    I would love to know if there is a way that i can override the parent functions.php file in a child theme.
    I have installed the Dokan plugin and the theme too, but i would love to override some of the functionalities in the functions.php file, I don't won't to do that in the parent file in order to get all the updates and all the new features.
    And can you tell me what are the required files that i have to put in my child theme in order to make it work properly.
    For example, the file that I want to override is the template-tags.php file, this file is being called from the functions.php file, and there are more stuff that I want to customize too.

    Thanks.

    #31721

    Nayem
    Moderator
    Post count: 6480

    Hello Hovsep,

    In your child theme you have to maintain the file order of the main theme. You can use any file which you want to customize but you have to maintain the same file order as main theme. Hope you got it.

    Thank you 🙂

    #31730

    Hovsep
    Member
    Post count: 7

    I'm doing that but it's not working, i have figure out why but i can't fix it.
    The file that i'm talking about is beeing called from the parent function.php file, so it always loading the parent file, when i do the same in my child theme, i'm getting a duplication error…can you help ?

    #31800

    Sekander Badsha
    Member
    Post count: 2067

    Hello Hovsep,

    Can you please tell us exactly which function you want to override?
    It would be easy for us to instruct you can be more specific.

    #32046

    Hovsep
    Member
    Post count: 7

    Basically what I’m trying to do is the following:
    the dokan theme has a top right menu which in it we have the sign up button and the and login and the cart if you are not signed in, so let’s call that the top menu…. What I want to do is bring that menu from the top and include it in to my main menu, so I will have my menu and the dokan theme user menu as one.
    in order to do this I have located where the code is and included it to my menu, the function was dokan_header_user_menu(), so I want to remove the ‘ul' tags from this menu in order to style the menu properly, and have more control on how it’s going to behave.
    I don’t want to chage the main dokan theme files cuz it have a lot of features that I want to use, so I wanna know if there is a way that I can override the template-tags.php file, which has the dokan_header_user_menu() function.
    thanks

    #32073

    Nayem
    Moderator
    Post count: 6480

    Hello Hovsep,

    Please follow the following instruction-

    1. Copy header.php file from the parent theme and paste it to your child theme.
    2. You have to copy this function dokan_header_user_menu() to child themes function.php and change the name of this function name as you want. You can do whatever you want to do with this function.
    3. Now you have to open your child theme's header.php file then you have to replace this function dokan_header_user_menu() to your new function which you have changed in function.php.

    Please check and let me know. Thank you 🙂

    #32212

    Hovsep
    Member
    Post count: 7

    thanks a lot, it works.

    #32213

    Nayem
    Moderator
    Post count: 6480

    Hello Hovsep,

    Very glad to know that. If you have no more problem then please mark this topic as resolved.

    Thank you 🙂

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

The topic ‘Overriding the functions.php parent file in a child theme’ is closed to new replies.