Skip to content

Instantly share code, notes, and snippets.

@BhargavBhandari90
Created July 20, 2020 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BhargavBhandari90/8a5218d486d9842daf9a53bdfa1b0d3e to your computer and use it in GitHub Desktop.
Save BhargavBhandari90/8a5218d486d9842daf9a53bdfa1b0d3e to your computer and use it in GitHub Desktop.
Create custom widget area
<?php
/**
* Create custom sidebars.
* Add this into your theme's php file where you want put all the custom
* widget area code.
*/
function my_register_sidebars() {
/* Register the 'primary' sidebar. */
register_sidebar(
array(
'id' => 'after-page-content',
'name' => __( 'After Single Page Content' ),
'description' => __( 'This will shows widget after single page content.' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
)
);
/* Repeat register_sidebar() code for additional sidebars. */
}
add_action( 'widgets_init', 'my_register_sidebars' );
/************************** Display on frontend ********************************/
/**
* Add this where you want to display your widget area on frontend.
*/
if ( is_active_sidebar( 'after-page-content' ) ) {
dynamic_sidebar( 'after-page-content' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment