Register Sidebar for Oxygen Builder

Arshad
20 May 2022

As Oxygen Builder disables the theme, so as there is no sidebar is available for using widgets from WordPress Admin area and WordPress Customizer. Here is the code to add a sidebar (widget area) as a solution.

As a developer and having knowledge of Oxygen, you can do it in Oxygen natively but for the client manage-able things, it is necessary to create a sidebar and give the client an area to manage their widgets like Recent Posts, Calender, Categories, Sidebar Menus etc.

This can be useful to give clients ability to change their sidebar easily without touching the Oxygen Builder. If they want to change content they can, but if they need to change styling then Oxygen knowledge is must otherwise their developer can do it.

<?php
add_action('widgets_init', 'my_register_sidebars');
function my_register_sidebars()
{
    /* Register the 'primary' sidebar. */
    register_sidebar(array(
        'name'         => __('Primary Sidebar', 'sitename-without-spaces'),
        'id' => 'primary-sidebar',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h3 class="widget-title">',
        'after_title'  => '</h3>',
    ));
    /* Repeat register_sidebar() code for additional sidebars. */
}
?>

How to use this

You can use Code-Snippets or Scripts Organizer to register it. I prefer Script Organizer.

Create a new code block with Trigger Location Everywhere, and Script Location PHP.
You can also use more conditions if you need to display it on selected templates or pages.

Here is a download-able snippet for Scripts Organizer.

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy