1

How can I add the widget manually in the code ?

2 Answers 2

6

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>
0

Depending on how your call to dynamic_sidebar() is setup, you should be able to drop them in before or after the function. For example:

<div id="sidebar">
    <ul class="sidebar">
        <!-- Your Widget Here -->
        <?php dynamic_sidebar(); ?>
    </ul>
</div>

You can put your widget (as an <li> in this case) right in there and voilà!

1
  • can I call any widget manually? e.g <?php word_tube_widget(); ?> Jan 17, 2012 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.