How to add the widgets manually to the sidebar?

How can I add the widget manually in the code ?

2 Answers
2

Have a look at the the_widget() function. The first argument is required. It is the PHP class name of the widget. For example:

<div class="sidebar">
  <?php the_widget('WP_Widget_Search') ?>
</div>

You can also pass on extra arguments:

<div class="sidebar">
  <?php the_widget('WP_Widget_Text', 'title=Hello&text=World') ?>
</div>

Leave a Comment