Many of the times, we saw that we are not able to do some very easy tasks. One of them is “Adding widgets in wordpress”. In this tutorial, I will show you how to “Add widgets in wordpress”.
Follow these steps:
Open yourfile and then copy and paste the following code in that file:
'id' => 'category'
add_action( 'widgets_init', 'arphabet_widgets_init');
Now Go to the admin section of your wordpress website and then go to Appearance/ widgets. There you will see the widget title with name “footer”. This was the name given in the code as ‘name’ => ‘footer’.
Now drag and drop the widgets you want to add to your widget area.
Now your widget is set. Its time to use those widgets in your page. To do so you have to open that page in which you want to show the widget. Generally, we add widgets to the sidebar or in the footer. In this tutorial, I am adding widget to the footer so I will open thefile and then add the following code to it.
<?php dynamic_sidebar( 'search' ); ?>
Note: Here ‘search’ is the id given in the code infile as ‘id’ => ‘search’
Now your page is ready with your widget.