Widgitize the Sidebar

Right, I have been working with wordPress for a long time now. I was recently working on a WordPress theme and working on the sidebar. You know that Sidebar’s are widgitized so if you are looking for a quick way to add a sidebar widget follow this quick method.

 

if (function_exists("register_sidebar")) {
  register_sidebar(array(
    'name' => 'left-sidebar',
    'before_widget' => '<div class="side-widget">',
    'after_widget' => '</div>',
    'before_title' => '<h2>',
    'after_title' => '</h2>',
));
}

Right, this code goes into the functions.php file of your active theme. This function adds a Widget in your theme.

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('left-sidebar') ) : ?>
<!-- Add your stuff here -->
<?php endif; ?>

The code above goes in your sidebar or your where you want to add the sidebar.

 

Cheers.

 


Warning: count(): Parameter must be an array or an object that implements Countable in /home/alihs/domains/alihussain.me/public_html/blog/wp-includes/class-wp-comment-query.php on line 399

Leave a Reply

Your email address will not be published. Required fields are marked *