WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to use one stylesheet for several blogs? (8 posts)

  1. deko
    Member
    Posted 8 years ago #

    I have several WP blogs each with the exact same theme. Each is installed in its own folder, like this:

    public_html/wp01
    public_html/wp02
    etc. etc.

    It's working fine, but I would like to centralize whatever I can, especially the stylesheet.

    In the header.php files I see this:

    <?php bloginfo('stylesheet_url'); ?>

    Is there anyway I can modify whatever this is so everything points to public_html/style.css ?

    Thanks in advance.

  2. Chris_K
    Member
    Posted 8 years ago #

    You could change
    <?php bloginfo('stylesheet_url'); ?> in the theme files to be an absolute url to the one common stylesheet.

  3. deko
    Member
    Posted 8 years ago #

    There are a couple of problems with that idea, but yes, that's one way. An better way woud be to redefine that tag/variable somehow - if I knew how...

  4. deko
    Member
    Posted 8 years ago #

    I tried hard-coding the path to a stylesheet a few directories up but that did not work.

    How do I set the stylesheet_url to a different value?

  5. moshu
    Member
    Posted 8 years ago #

    stylesheet_url will work only inside one (1) installation.
    When HS said absolute path, he meant (I assume)
    h t t p: // example.com/whatever/style.css

    Edit. And replace the template tag with the absolute path.

  6. Chris_K
    Member
    Posted 8 years ago #

    correct, that's what I meant.

  7. Doodlebee
    Member
    Posted 8 years ago #

    I don't know if this would help...(I'm not sure I understand the original question) but, just in case...

    I have 4 stylesheets I need to use in my one blog page. It took some searching, but I discovered that if I changed this:

    <?php bloginfo('stylesheet_url'); ?>

    to this:

    <?php bloginfo('template_directory'); ?>/css/forms.css"

    I could have my stylesheets in one directory, and have the URL path show up to a point - and I could define the rest of it after. The original would always plug in the full path to my default stylesheet, down to "styles.css" - but the above code - placed in the "href" area, would allow me to just define up to my CSS *folder* and then I could just tack on "/stylesheet name here.css". Now all four of my stylesheets appear just fine. :)

  8. deko
    Member
    Posted 8 years ago #

    I think I figured it out.

    Here's the file I changed:

    wordpress/wp-includes/functions.php #line 1684

    Here's the change:

    function get_stylesheet_uri() {
    /*
    $stylesheet_dir_uri = get_stylesheet_directory_uri();
    $stylesheet_uri = $stylesheet_dir_uri . "/style.css";
    return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
    */
    return apply_filters('stylesheet_uri', "/style-wp.css", "/");
    }

    Now I can have as many blogs (separate installations) as I want (same theme) and just one stylesheet for all of them.

    Still testing, but so far it seems to work.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags