WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

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>
share|improve this answer
    
Thank you a lot, you were very helpful. It worked fine with little modifications. – kidwon Sep 20 '11 at 19:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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