33 C

How to create custom widget Area in the admin Widgets page?

Must read

Ayyaz Zafarhttps://www.ayyaztech.com
I am Full Stack Web Developer with 10 years of professional Experience. I have following Skills: HTML5, CSS3, Javascript, jQuery, Ajax, PHP, MySQL, jQuery, Angular, React.js, Wordpress, Codeigniter, Laravel, Node.js, Mongo DB, Express.js, GraphQL, Typescript, Apollo and many more..

To create custom widget area we will need functions.php file (should be in the root directory of the theme) to add some custom code. We use wordpress filter “widgets_init”.

function register_my_sidebar()

  $args = array(
	'name'          => __( 'Footer 1', 'theme_text_domain' ),
	'id'            => 'footer-widget-1',
	'description'   => '',
        'class'         => '',
	'before_widget' => '<li id="{3b3dd3986446f2411a115859dfb9ef0645ca07550196603d49955fcfabeac62d}1$s" class="widget {3b3dd3986446f2411a115859dfb9ef0645ca07550196603d49955fcfabeac62d}2$s">',
	'after_widget'  => '</li>',
	'before_title'  => '<h2 class="widgettitle">',
	'after_title'   => '</h2>' ); 
    register_sidebar( $args );

add_filter('widgets_init', 'register_my_sidebar');


You can copy paste this code in your functions.php file to see results.

Result will look like in the screenshot below ( Inside the admin panel > Appearance > Widgets ):


- Advertisement -spot_img

More articles


Please enter your comment!
Please enter your name here

Latest article