0

Hey guys I'm trying to activate a sidebar for wp widgets.

So my HTML looks like this:

<aside id="leftSidebar">
   <section>
      <h3></h3>
      <div class="contents"></div>
   </section>
</aside>

So I want to put the widget inside "contents" and its title in h3 tag. How my activate function should be and what php to put in my html if needed? I didn't find any examples near mine so I appreciate any help 10x a lot in advance.

1

You would register the sidebar in the functions.php file with something like this:

<?php
register_sidebar(array('name'=>'custom-content',
 'before_widget' => '<section>',
 'after_widget' => "</section>",
 'before_title' => '<h3>',
 'after_title' => "</h3>"
  ));
?>

And Use it in your theme like this:

<div class="contents">
<?php if ( function_exists(dynamic_sidebar(1) ) ) : ?>
    <?php dynamic_sidebar(custom-content); ?>
<?php endif; ?>
</div>
  • Thank you a lot, you were very helpful. It worked fine with little modifications. – kidwon Sep 20 '11 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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