WordPress.org

Support

Support » Themes and Templates » Stylesheet directory code snippet

Stylesheet directory code snippet

  • Hi!

    Usually the link to a stylesheet is called using this line of code:

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

    This line use the URL to point to the stylesheet location. But that won’t work on the site I’m working on, because it has two URL’s pointing to the same site.
    Would it be possible to point to a directory? For example with this piece of code:

    $current_stylesheet_dir

    Thanks a lot in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Stef,
    The main call for style.css in header.php and this file name should only exists the once, and does not need the file name:
    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />

    Not sure what you mean by two URL’s, do you mean you have two files?

    If you do the second file should not start with style and you can call it like this, UNTESTED code:

    If you had a second stylesheet in a subfolder /styles/ in a parent theme:
    <link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri() .'/styles/custom.css"'; ?> media="all" />

    If you use a child theme and had a second stylesheet in a subfolder /styles/ in a child theme:
    <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri() .'/styles/custom.css"'; ?> media="all" />

    HTH

    David

    The problem is that I have two urls pointing to the same site:
    http://www.noinknoglory.com/
    http://www.noinknoglory.nl/

    Firefox doesn’t want to load my custom fonts… That’s the problem 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Stylesheet directory code snippet’ is closed to new replies.
Skip to toolbar