WordPress – A well known CMS available in market to build stunning business websites and ecommerce websites. It gained so much popularity due to its ease of working and customization ability for any type of business to go online in no time. WordPress is a content management system(CMS) initially it is designed to create “Blog” type of website only, but now we can create ecommerce websites (with WooCommerce plugin), subscription based membership and other simple websites for targeting small to medium or even big ecommerce website/business. WordPress also comes with lot of features that helps Digital Marketing Agency in online promotion or digital marketing of their website.
Most of the websites follow traditional pattern of having left or right sidebar for quick links, promotional content or quote form. In this blog we would like to give you an quick idea “How to create a widget in wordpress in simple way without using any plugin“, so let’s start creating widget.
For this, we are using ”Twenty Seventeen” theme that comes with default WordPress installation.
Steps for creating widget:-
- Go to your theme folder in our case “wp-content\themes\twentyseventeen”.
- Open a file “function.php” in your respective theme folder.
- Search function name “twentyseventeen_widgets_init()” in “function.php” ( at line no. 313 ).
- Copy and paste the “register_sidebar” within the same function “twentyseventeen_widgets_init()”.
- Make changes in “register_sidebar” as per your widget requirement.
‘name’ => __( ‘Copyright Text’, ‘twentyseventeen’ ),
‘id’ => ‘sidebar-copyright’,
‘description’ => __( ‘Copyright Text.’, ‘twentyseventeen’ ),
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
- Login to admin panel “mydomain.com/wp-admin”.
- Click on “widget” under “Appearance” menu link in the left navigation. you will see the below sidebar.
8: Now drag and drop the “text widget” available on the same page in your new widget
9: After that add quick links, quote form or any other promotional item that you want to appear in the sidebar and click on save button
Now you have done with WordPress admin for creating widget.
Next step is “how to make it visible on frontend”.
Copy & paste the following code in the page template where you would like to display this new idebar and save the file.
<?php dynamic_sidebar(‘sidebar-copyright’); ?>