1

I am using a WordPress theme which has just header and footer. I would like to continue using it by changing the width and adding side bars.

Could anyone help me to change the width (to fit to the screen) of the theme. Does anybody have an idea on how to add sidebars to this theme?

==========

Sorry for not making clear in my earlier question. The theme I am using is Minicard

The lines similar to ...

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

are already there.

This is the code I found there:

if ( function_exists('register_sidebar') ) {

    register_sidebar(array(
        'name' => __('Beneath the Card (Top)', 'minicard'),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '<div class="clear"></div></li>',
        'before_title' => '<h2 class="section widgettitle">',
        'after_title' => '</h2>',
    ));
    register_sidebar(array(
        'name' => __('Beneath the Card (Bottom)', 'minicard'),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '<div class="clear"></div></li>',
        'before_title' => '<h2 class="section widgettitle">',
        'after_title' => '</h2>',
    ));
}

So I have created sidebar.php file and added the code you have given for side bar.

Later I have tried to add the following code:

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

to CSS.

After making these changes I've looked for the sidebar and I havn't found any additional one.

3
  • 1
    Please delete your answer below, and move the additional information in your answer to your question. Answer posts should be reserved for actual answers to the question, not for responding to another answer. Commented Aug 27, 2010 at 13:41
  • As @tnorhtcutt said, please put that in your question. Next to that please name the theme you are using and provide a link. That would help a lot.
    – hakre
    Commented Aug 27, 2010 at 21:56
  • I have deleted my answer and added it to my question itself .I have also added the theme details . Please let me know I am missing anything !
    – user391
    Commented Aug 29, 2010 at 13:42

2 Answers 2

1

Generally you can change the width from style.css file, which is located in the themes directory ( use firebug to determine the element ).

For adding sidebars... use this tutorial.

0
1

@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.

1
  • Could you tell me that how to change the CSS code in the main wrapper div? I have find the particular div tag there .But I am not sure what to change. I know some php .But newer to CSS .
    – user391
    Commented Aug 27, 2010 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.