mmp460

Class Information, Notes and code samples for MMP 460

slack

Adding a sidebar

Simplest Sidebar

Register the sidebar in functions.php:

    register_sidebar();

Display the sidebar on any of your theme templates with the following line:

    <?php get_sidebar(); ?>

Populate the sidebar in the Dashboard>Appearance>Widgets


Sidebar that allows more customization

Register the sidebar in functions.php:

    /* registering the sidebar */
        $basic_portflio= array(
        'name' => 'Sidebar1',
        'id' => 'sidebar1',
        'description' => 'Widgets placed here will be displayed in the right side of the page',
        'before_widget' =>'<div class="widget">',
        'after_widget' =>'</div>',
            'before_title' =>'<h3>',
        'after_title' =>'</h3>',
            );
    register_sidebar($basic_portflio);
    /* Adding support for Featured Images */
    add_theme_support( 'post-thumbnails' );
    ?>

Create sidebar.php with (at the minimum) the following code:

<div id="sidebar">
<?php
dynamic_sidebar('Sidebar1');
?>
</div>

Note that the parameter ‘Sidebar1’ is the sidebar name given in functions.php.

Display the side bar on any of your theme templates with the the following line:

   <?php get_sidebar('sidebar1'); ?>