WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Style.css & Configuration.php files (3 posts)

  1. schaef2493
    Member
    Posted 6 years ago #

    I'm setting up a complex website and I'd like to be able to use two stylesheets. One will be used for static pages and one will be used for the frontpage. Is there anyway to use two in WordPress?

    Also, I'd like to totally remove the sidebar from the static pages and stretch the content to fill the space previously occupied by the sidebar. I can stretch the content using the Configuration.php file but I'm not sure how to have two and specify a page template to use one or the other. Is there a better way to do this?

    Thanks in advance!

  2. stvwlf
    Member
    Posted 6 years ago #

    I'm setting up a complex website and I'd like to be able to use two stylesheets. One will be used for static pages and one will be used for the frontpage. Is there anyway to use two in WordPress?

    In your header.php file, something like this:

    <?php
     if (is_front_page) { ?>
       <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/style.css" />
    <?php } else { ?>
       <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/style2.css" />
    <?php } ?>

    Also, I'd like to totally remove the sidebar from the static pages and stretch the content to fill the space previously occupied by the sidebar. I can stretch the content using the Configuration.php file but I'm not sure how to have two and specify a page template to use one or the other. Is there a better way to do this?

    The best way would be to make a home.php template that will be used on your front page (WordPress automatically uses a template with that name on the front page, if it exists).

    Then modify your page.php file so it is formatted as you want the static pages to look (remove the call that loads the sidebar)

    You will find certain ID's or classes are defined in the CSS with certain widths. Your best bet is to override the CSS - add a class to the static pages.

    Example:
    Assuming you make a home.php page, you will probably see
    <div id="contents">

    and in the css you will see "contents" defined with something like
    #contents {
    width: 600px;
    }

    In page.php change the above div to this
    <div id="contents" class="wide">

    and in the CSS, add a line that says
    #contents.wide {
    width: 850px;
    }

    That will override the default styling by making the div contents be 850 pixels wide when it has a classname of "wide".

    Your best bet is to install the Firefox Firebug extension, which shows you everything there is to see about the CSS being applied to your pages. It will help you get everything set up correctly.

  3. schaef2493
    Member
    Posted 6 years ago #

    Thanks, that was a huge help. One thing, it seems that the is_front_page conditional is being returned as true no matter what. The only way I can get the second style sheet to display is if I change "style.css" to "style2.css".

    Thanks again.

Topic Closed

This topic has been closed to new replies.

About this Topic