Black Screen Issue: Please update your theme to ensure WordPress 5.6 compatibility. Dentalia 2.1 and Recycle 2.1 are now available on ThemeForest. 

Okay
  Public Ticket #2004995
Override Orion widgets templates
Closed

Comments

  •  2
    clementpolito started the conversation

    Hi !
    Thank you for your theme.
    I have to modify templates of several Orion widgets as orion_recent_posts_carousel-template.php or orion_working_hours_w-template.php.
    I didn't find doc about it, or comments in the code. Usually, I have to recreate the exact hierarchy in my child theme, but it doesn't work here.

    How can I override files of dentalia theme ? 
    Thank you 

  •  532
    OrionThemes replied

    Hi,

    As widgets are not theme templates, the classic WordPress procedure for overwriting theme templates will not work. In order to keep your changes upon theme upgrade, the safest way is to duplicate and rename the widget you want to modify. As each widget is a separate php class, they must be renamed, as the name of any php class must always be unique. 

    Also in order to keep the new widget in your child theme, a widget folder in your child theme must be registered with the SiteOrigin Page builder. Let's start with this part:

    1. Register the widget folder in your child theme:

    Add this to your child theme functions.php file:

    function orion_child_add_widget_folders( $folders ){
        $folders[] = get_stylesheet_directory() . '/yourwidgetfolder/';
        return $folders;
    }
    add_filter('siteorigin_widgets_widget_folders', 'orion_child_add_widget_folders');

    Change 'yourwidgetfolder' to your actual folder's name.

    2. Rename the widget: 

    Copy entire widgets/so-widgets/orion-recent-posts-carousel/ to your child theme's widget folder. 

    2.1 Now rename this folder to something else like c-recent-posts-carousel

    2.2 Inside this folder, there is a file orion-recent-posts-carousel.php -> rename it to c-recent-posts-carousel.php

    2.3 There is also a tpl folder inside theRecent post widget folder, inside there is a file orion_recent_posts_carousel-template.php -> Rename it to c_recent_posts_carousel-template.php

    2.4 Open the /yourwidgetfolder/c-recent-posts-carousel/c-recent-posts-carousel.php file with a text editor. Now find and replace 'orion_recent_posts_carousel' with 'c_recent_posts_carousel'. Also change the name of the widget, replace '(OrionThemes) Recent Posts' with 'New Recent Posts'.

    3. Activate it: Now everything is ready, you just need to activate the new widget. In WordPress Dashboard go to Plugins -> SiteOrigin Widgets. Find your New Recent Posts widget and activate it.

    Now just place your new widget in place of your old one.

    Let me know, how it goes.

    Andrej

  •  2
    clementpolito replied

    Hi Andrej,

    Thank you for your feedback.
    It works only if I also rename 'get_category_array' and 'post_limit_array' functions and options.
    Otherwise, I have this errors :

    Fatal error: Cannot redeclare get_category_array()
    Fatal error: Cannot redeclare post_limit_array() 

    Is it ok for you, or have I to unregister the original widget to register the modified one ?

  •  532
    OrionThemes replied

    Hi 

    Yes you're right. Thank you for getting back on this. I forgot about those extra functions.
    If you rename them, then you can have both versions of the widgets enabled. It shouldn't make any noticable difference in loading speed/performance.

    Kind regards,
    Andrej

  •  2
    clementpolito replied

    Hi,

    Perfect, thank you very much Andrej !

    Clement