To register a sidebar widget, head over to Appearance > Editor
and select the function.php
from the right side. Then copy and paste this code at the end of your function.php
file.
function custom_register_widgets() {
register_sidebar( array (
'name' => __( 'Sidebar widget'),
'id' => 'sidebar-custom',
'description' => __( 'Widgets dragged here will appear in the right sidebar.' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h5 class="widget-title"><span>',
'after_title' => '</span></h5>'
) );
}
add_action( 'widgets_init', 'custom_register_widgets' );
Now you need to call your widget in order to display it. Again from the right side, select sidebar.php
and paste this code in the place you need:
<?php
if(is_active_sidebar('sidebar-custom')){
dynamic_sidebar('sidebar-custom');
}?>