WordPress.org

Ready to get started?Download WordPress

Forums

Need the location of the style sheet be a local path rather than a full URL (7 posts)

  1. jbadger
    Member
    Posted 6 years ago #

    Sorry in advance for the long post, but I need to tell the full story here to explain the problem...

    The following style sheet declaration in my header.php file:

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

    Is expanded by PHP to the following, as expected:

    <link rel="stylesheet" href="http://news.pandesa.com/wp-content/themes/zenful_pandesa/style.css" type="text/css" media="screen" />

    I am wondering if there isn't a way to have the location of the style sheet expand to a standard local directory reference rather than a full URL.

    Why, you might ask, would I want to do away with the full URL?

    The answer is that I have found that this full URL is slowing down the superfish dropdown menus in IE6. Check out this page in IE6:

    http://news1.pandesa.com/

    Notice how slow and clunky the dropdowns are in IE6? Now check out the following page in IE6:

    http://news1.pandesa.com/wp-content/themes/zenful_pandesa/test1.htm

    Notice how nice and fast the dropdowns are now? Thats how they are supposed to work.

    This latter URL was generated by first doing a "View -> Page Source" and dumping the resulting HTML into a file, which resulted in this:

    http://news1.pandesa.com/wp-content/themes/zenful_pandesa/test.htm

    Notice that this last page exhibits the exact same slow behavior in IE6. All I did to fix the problem was to replace the style sheet declaration:

    <link rel="stylesheet" href="http://news.pandesa.com/wp-content/themes/zenful_pandesa/style.css" type="text/css" media="screen" />

    with this:

    <link rel="stylesheet" href="style.css" type="text/css" media="screen" />

    So, thats why I'm suspecting that the speed issue is related to using the full URL.

    I tried to just remove the bloginfo('stylesheet_url'), but I can't seem to make it find my stylesheet.

    Does anybody have any advice? I've been working on this problem on-and-off for weeks!

    Thanks!

  2. jbadger
    Member
    Posted 6 years ago #

    I'm still trying to figure out how to resolve this - any help here would be greatly appreciated.

    By the way, the 3rd URL in the previous post is incorrect - the page that is working is at:

    http://news1.pandesa.com/wp-content/themes/zenful_pandesa/test1.htm

  3. whooami
    Member
    Posted 6 years ago #

    youve really made this hard to follow and much more difficult than necessary.

    you cant use relative paths like this unless you start from the root directory.

    why? because a page that looks like this

    http://www.domain.com/categories/zzz

    has a different relative path than this

    http://www.domain.com/

    ../mystylesheet is not the same.

    you need to start at the root of your install

    Look at this:

    http://www.village-idiot.org/css-test/test1.htm
    http://www.village-idiot.org/css-test/one/test1.htm
    http://www.village-idiot.org/css-test/two/three/test1.htm

    All those pages are using the same stylesheet, and they all know where to find it because I have used language that tells the server to start at web-root.

    <link rel="stylesheet" href="/css-test/css/style.css" type="text/css" media="screen" />

    2 weeks for this?

    Im for hire if that business needs someone that can actually ...

  4. jbadger
    Member
    Posted 6 years ago #

    Hi Whoami,
    Thanks for the response. The above question is actually an attempt at a hack to fix a problem with superfish dropdowns as described here:

    http://groups.google.com/group/jquery-en/browse_thread/thread/3892a06f70e46e29

    As you can see, the problem with this page under IE is that superfish for some BIZARRE reason, it slows WAY down when I use an http absolute path to refer to the CSS file.

    You say here that relative paths won't work with WordPress... OK, so now I'm wondering if an absolute path that doesn't go all the way out to the http level will work for some strange reason - I'm grasping for straws here since none of this makes sense, but its worth a try...

    ...the problem is that I have tried using absolute paths, but unless I use bloginfo to generate the path to the css file, it doesn't seem to work - it can't find my css. And bloginfo only generates paths that start with 'http:' which seems to be causing the problem.

    You were wondering if "that business" needs help from somebody that can actually... And the answer is YES! I'm "that business" and I'm way out of my league trying to fix this issue. The original programmer for the site is no available and I'm obviously not a programmer - I'm a marketing guy. My guess is that this will only take less than an hour to fix, but I'm sure there will be other things we'll need help with in the future. If you think you can fix this quickly without turning it into a research project, please email me at jbadger@pandesa.com.

    - John

  5. jbadger
    Member
    Posted 6 years ago #

    Well, its fixed now, but it ain't pretty. It would be much cleaner if I could figure out some way to make bloginfo return a pathname that started with "/" rather than one that starts with "http://". Oh well.

  6. dave_t
    Member
    Posted 6 years ago #

    This might be a bit late, but I think what Whoami was trying to tell you was to use a relative path starting from the web-root to your theme folder. You mentioned an absolute path that doesn't go all the way out to 'http/' - the following works for me:

    <link rel="stylesheet" href="wp-content/themes/my_theme/my_style.css" type="text/css" media="screen" />

  7. buchannon
    Member
    Posted 5 years ago #

    I just ran into this problem as well jbadger.

    dave_t, yes that works as a relative path, but it's not dynamic. We want something like "bloginfo('template_directory')" that returns a relative path and not a URL beginning with "http".

    It seems weird that this is a pretty basic thing, yet WP doesn't have a built in function to do it?

Topic Closed

This topic has been closed to new replies.

About this Topic