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>',
));
?>


2 comments:

Wordpress Development Company said...

Nice widget for wordpress.

Anonymous said...

thanks for share
Wordpress is the best CMS all platform, so friendly and many benefit
i also want to share free premium theme wordpress for people
free premium themes wordpress
Maybe help something to you
thanks so much