WordPress - Creating new widget positions

⚠️ Warning: To create a new widget position, always use ftp! The functions.php file of your theme has to be modified, and if you make an error in it, not just the frontend, but the backend of your website will be blank too, so you won't be able to fix the problem from there!

Your theme's files are located at: wp-content/themes/[your_theme]/

Add this code to your theme's functions.php file (it should be fine in the very bottom, after all other codes):

function smartslider_widgets_init() {
    register_sidebar(array(
        'name'          => 'Widget Position for Smart Slider',
        'id'            => 'nextend_smart_slider_widget_position',
        'before_widget' => '<div class="smart_slider_widget_container">',
        'after_widget'  => '</div>'
    ));
}
add_action( 'widgets_init', 'smartslider_widgets_init' );

If you will want to create more widgets, just list new "register_sidebar"-s inside the function, and give a unique id for them:

function smartslider_widgets_init() {
    register_sidebar(array(
        'name'          => 'Widget Position for Smart Slider #1',
        'id'            => 'nextend_smart_slider_widget_position',
        'before_widget' => '<div class="smart_slider_widget_container">',
        'after_widget'  => '</div>'
    ));
    register_sidebar(array(
        'name'          => 'Widget Position for Smart Slider #2',
        'id'            => 'nextend_smart_slider_widget_position_2',
        'before_widget' => '<div class="smart_slider_widget_container">',
        'after_widget'  => '</div>'
    ));
    register_sidebar(array(
        'name'          => 'Widget Position for Smart Slider #3',
        'id'            => 'nextend_smart_slider_widget_position_3',
        'before_widget' => '<div class="smart_slider_widget_container">',
        'after_widget'  => '</div>'
    ));
}
add_action( 'widgets_init', 'smartslider_widgets_init' );

After this, find out which codepart creates that part of your theme, where you want to have this new widget position, and also find that codepart between your theme's files. You can find a documentation here for this.

When you got the file and codepart, insert this PHP code there:

<?php
if ( is_active_sidebar( 'nextend_smart_slider_widget_position' ) ){
    dynamic_sidebar( 'nextend_smart_slider_widget_position' );
}
?>

If you are putting the code into a PHP codepart, then you don't need the <?php and ?> parts:

if ( is_active_sidebar( 'nextend_smart_slider_widget_position' ) ){
    dynamic_sidebar( 'nextend_smart_slider_widget_position' );
}

And you can use the same code for your other widget positions as well, with their id-s. 

After this you will see the new widget position appearing in your backend's Appearance → Widgets, and you will be able to drag our slider's widget inside it:

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.