How To Create Your Own Custom Widgets Wordpress
How To Create Your Own Custom Widgets Wordpress
Wordpress provide a functionality to create your own custom widgets for this we have function that initilize your widget widgets_init. By using this function you can initilize your custom widget and call them by using dynamic_sidebar('customsidebarwidget'). Let create our own widget
Wordpress provide a functionality to create your own custom widgets for this we have function that initilize your widget widgets_init. By using this function you can initilize your custom widget and call them by using dynamic_sidebar('customsidebarwidget'). Let create our own widget
function custom_sidebar_widget(){ register_sidebar(array( 'name' => __('Custom Sidebar Widget', 'customsidebarwidget'), 'id' => 'customsidebarwidget', 'description'=> __('Your description about your widget', 'customsidebarwidget'), )); } add_action( 'widgets_init', 'custom_sidebar_widget' );custom_sidebar_widget it's name of function that you used with widgets_init in Hook i.e. add_action( 'widgets_init', 'custom_sidebar_widget' ). and inside this function you can describe your widget detail inside register_sidebar in the form of array name,id,description. after creating widget you can check your widget area follow Apperence->Widget in Admin section and you have your own create custom widget is there. pic here now you can call this widget any page by using the below code
if(is_active_sidebar('customsidebarwidget')){ dynamic_sidebar('customsidebarwidget'); }and check your page your content inside widget is showing there after inserting above code. Thanks if any query let me know.
Comments
Post a Comment
If you have any error, bug related to your Prestashop website, Let me know