How to make wordpress theme's Sidebar Widget Ready ?

it is very easy to make any wordpress theme's sidebar widget ready. in first step add following code to functions.php file if does not exists than create one.

<?php
register_sidebar();
?>


now add following code in your sidebar.php if does not exists than create one.

<aside>
<?php if ( !dynamic_sidebar() ) : ?>
<h2>Sidebar</h2>
<?php endif; ?>
</aside>


Congrats. You have a widget ready sidebar.

Code with some default and basic Styling.

for sidebar.php



<aside>
<?php if ( !dynamic_sidebar() ) : ?>
<h2>About</h2>
<p>This is my blog. i Love Wordpress.</p>
<?php wp_loginout(); ?>
<?php endif; ?>
</aside>


For functions.php



<?php
register_sidebar(array(
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
?>


Reactions:

3 comments: