WordPress.org

Ready to get started?Download WordPress

Forums

Custom stylesheet URL? (8 posts)

  1. nielskreijveld
    Member
    Posted 5 years ago #

    Hello people,

    I have a question about stylesheets. I've put the CSS files from my theme in the /CSS directory. In my header.php file I've hard-coded the URL to the stylesheet like so:

    <link rel="stylesheet" href="<?php echo bloginfo('template_directory'); ?>/css/stylesheet.css" type="text/css" media="screen" />

    This works fine as long as I don't open the template manager in the backend. As soon as I do that WordPress reverts to the standard theme because it thinks the stylesheet of my theme is broken (which makes sense: I have no style.css file in my theme directory).

    How do I change the stylesheet URL so that the backend sees my stylesheet?

    Thnx in advance!

  2. nielskreijveld
    Member
    Posted 5 years ago #

    I found a workaround. You place a style.css file in your theme's main directory, and you keep your code in your header as mentioned above. This way the backend thinks you are using style.css, and it doesn't revert to the classic theme. It's a bit silly, because you need one additional file to make it work, so I would rather have a more elegant solution.

    Can anyone help me?

  3. thisisedie
    Member
    Posted 5 years ago #

    My question is... why do you want the stylesheet somewhere other than the theme folder?

  4. nielskreijveld
    Member
    Posted 5 years ago #

    Organisation... Javascript in the /js folder, flash in the /flash folder, css in the /css folder. I've been building websites with that structure for ages, I am a neat freak...

  5. nielskreijveld
    Member
    Posted 5 years ago #

    And the /css folder is still in the theme folder :).

  6. jeffersons
    Member
    Posted 4 years ago #


  7. Talton
    Member
    Posted 4 years ago #

    I'm trying to find the same solution. I usually put my CSS code in a CSS folder as well and would like to keep it that way.

  8. Talton
    Member
    Posted 4 years ago #


Topic Closed

This topic has been closed to new replies.

About this Topic