Skip to content

Instantly share code, notes, and snippets.

@Njengah
Last active January 18, 2020 23:20
Show Gist options
  • Save Njengah/010453c11d170df9b9c8de2f31954a5d to your computer and use it in GitHub Desktop.
Save Njengah/010453c11d170df9b9c8de2f31954a5d to your computer and use it in GitHub Desktop.
Functions to register sidebar in WordPress
<?php
//Callback function
function njengah_register_sidebar_tutorial() {
//Register Sidebar function - https://developer.wordpress.org/reference/functions/register_sidebar/
register_sidebar(
array(
'name' => __( 'Sidebar Example', 'textdomain' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'textdomain' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
)
);
}
// Action hook
add_action( 'widgets_init', 'njengah_register_sidebar_tutorial' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment