Skip to main content
Corrected syntax
Source Link
Krzysiek Dróżdż
  • 25.5k
  • 9
  • 53
  • 74

@user391,

If you want to use sidebar widgets, add the following code to your functions.php file

if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar Widgets', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>', ));functions.php file

if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'name' => 'Sidebar Widgets',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3 class="widgettitle">',
        'after_title' => '</h3>',
    ));

Next you will need to determine the cssCSS id or class that wraps your main content or posts. Usually this can be found by looking at your index.phpindex.php file right underneath <?php get_header(); ?>

You should see something like <div id="content"> but it might be named something else. At the bottom of the page look for the closing div ie: </div> which is usually right before <?php get_footer(); ?> some themes will close the content divs in footer.php if this is the case you will need to remove it from footer.php and put it right before <?php get_footer(); ?>

Next you need to add <?php get_sidebar(); ?> after the closing div and before <?php get_footer(); ?> and create a new template file named sidebar.php

Add the following code to sidebar.php

<div id="sidebar">

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Widgets') ) : ?><?php endif; ?>
        
 
</div><!--/sidebar-->

Next you will have to modify your CSS to accommodate the sidebar. Find #content or the id or class name you found above and change the width and float it left and add your sidebar we just created above. For example:

#content {
    width:620px;
    float:left
    }

#sidebar {
    width: 240px;
    float:right;
    padding:0 20px 20px;
    }

You might have to adjust the widths depending on the width of the main wrapper div.

You can now add content to the sidebar by using the widgets in your WordPress dashboard.

@user391,

If you want to use sidebar widgets add the following code to your functions.php file

if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar Widgets', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>', ));

Next you will need to determine the css id or class that wraps your main content or posts. Usually this can be found by looking at your index.php file right underneath <?php get_header(); ?>

You should see something like <div id="content"> but it might be named something else. At the bottom of the page look for the closing div ie: </div> which is usually right before <?php get_footer(); ?> some themes will close the content divs in footer.php if this is the case you will need to remove it from footer.php and put it right before <?php get_footer(); ?>

Next you need to add <?php get_sidebar(); ?> after the closing div and before <?php get_footer(); ?> and create a new template file named sidebar.php

Add the following code to sidebar.php

<div id="sidebar">

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Widgets') ) : ?><?php endif; ?>
        
 
</div><!--/sidebar-->

Next you will have to modify your CSS to accommodate the sidebar. Find #content or the id or class name you found above and change the width and float it left and add your sidebar we just created above. For example:

#content {
    width:620px;
    float:left
    }

#sidebar {
    width: 240px;
    float:right;
    padding:0 20px 20px;
    }

You might have to adjust the widths depending on the width of the main wrapper div.

You can now add content to the sidebar by using the widgets in your WordPress dashboard.

@user391,

If you want to use sidebar widgets, add the following code to your functions.php file

if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'name' => 'Sidebar Widgets',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3 class="widgettitle">',
        'after_title' => '</h3>',
    ));

Next you will need to determine the CSS id or class that wraps your main content or posts. Usually this can be found by looking at your index.php file right underneath <?php get_header(); ?>

You should see something like <div id="content"> but it might be named something else. At the bottom of the page look for the closing div ie: </div> which is usually right before <?php get_footer(); ?> some themes will close the content divs in footer.php if this is the case you will need to remove it from footer.php and put it right before <?php get_footer(); ?>

Next you need to add <?php get_sidebar(); ?> after the closing div and before <?php get_footer(); ?> and create a new template file named sidebar.php

Add the following code to sidebar.php

<div id="sidebar">

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Widgets') ) : ?><?php endif; ?>
        
</div><!--/sidebar-->

Next you will have to modify your CSS to accommodate the sidebar. Find #content or the id or class name you found above and change the width and float it left and add your sidebar we just created above. For example:

#content {
    width:620px;
    float:left
}

#sidebar {
    width: 240px;
    float:right;
    padding:0 20px 20px;
}

You might have to adjust the widths depending on the width of the main wrapper div.

You can now add content to the sidebar by using the widgets in your WordPress dashboard.

Source Link
Chris_O
  • 20.6k
  • 5
  • 61
  • 95

@user391,

If you want to use sidebar widgets add the following code to your functions.php file

if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar Widgets', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>', ));

Next you will need to determine the css id or class that wraps your main content or posts. Usually this can be found by looking at your index.php file right underneath <?php get_header(); ?>

You should see something like <div id="content"> but it might be named something else. At the bottom of the page look for the closing div ie: </div> which is usually right before <?php get_footer(); ?> some themes will close the content divs in footer.php if this is the case you will need to remove it from footer.php and put it right before <?php get_footer(); ?>

Next you need to add <?php get_sidebar(); ?> after the closing div and before <?php get_footer(); ?> and create a new template file named sidebar.php

Add the following code to sidebar.php

<div id="sidebar">

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Widgets') ) : ?><?php endif; ?>
        

</div><!--/sidebar-->

Next you will have to modify your CSS to accommodate the sidebar. Find #content or the id or class name you found above and change the width and float it left and add your sidebar we just created above. For example:

#content {
    width:620px;
    float:left
    }

#sidebar {
    width: 240px;
    float:right;
    padding:0 20px 20px;
    }

You might have to adjust the widths depending on the width of the main wrapper div.

You can now add content to the sidebar by using the widgets in your WordPress dashboard.