WordPress.org

Forums

bloginfo('template_directory'); generates ONLY absolute URL - how to get LOCAL? (6 posts)

  1. inkhaton
    Member
    Posted 5 years ago #

    So I am using
    bloginfo('template_directory');
    to prefix all references to my images.

    The problem is that there are many images on the site and since each URL is absolute, when the request is made, it is handled by the server as a new connection and with a moderate load of users, the maximum number of connections is reached.

    Is there any command to get the relative path for my template directory?
    Same goes for getting the bloginfo('home'); for the root.

  2. The problem there is not everyone has their 'home' in the same place. And not everyone uses the same folder structure.

    You could try somethign like this:

    <a href="/">Home</a>
    <a href="/wp-content/themes/">Themes</a>

    But you see how it'd have to be custom crafted?

  3. inkhaton
    Member
    Posted 5 years ago #

    Yea but the problem becomes that when you use a header on several pages and the home page is in the context root and another page that also uses the header but is in some sub directory the relative path link would be different so on one of the pages the images would be missing.

    The option to use bloginfo('home'); works but is inefficient and artificially multiplies traffic congestion on the web server.

    I need a function that gives me the relative path to m templates directory such that from
    http://www.domain.com
    it would give me the path
    "/wp-content/themes/"

    and from
    http://www.domain.com /subdir/
    it would give me something like
    "../wp-content/themes/"

    without making the inefficient ABSOLUTE URL of
    "http://www.domain.com/wp-content/themes/"
    every time

  4. That's a basic 'How websites work' question, though. The base link of /folder always points to domain.com/folder It's the leading / that says 'root of this site.'

    The problem is that there are many images on the site and since each URL is absolute, when the request is made, it is handled by the server as a new connection and with a moderate load of users, the maximum number of connections is reached.

    I'm not sure that's as big a deal as you're making it. I've never reached the max number of connections, even when I got Dugg. I have more a problem with PHP and SQL when it gets that bad, long before max connections is an issue.

    Between WP-Super-Cache and a good webhost, I don't have problems anymore and I know my theme still makes full http:// calls to css and js.

  5. inkhaton
    Member
    Posted 5 years ago #

    Thanks,

    I actually was able to get the references to images work with /wp-content/themes.......
    I just thought there would be a wordpress hook to get the link rather than having to manually replace all the urls.

    It's sort of a pain and surprising that the blgoinfo wouldn't by default use the relative link. I had about 60+ images on the page and the server (shared server) allows only 200 max connections.

    Speaking of db slowness, you wouldn't happen to know of a way to speed up the comments section on the admin portal? The site has over 100,000 comments and the queries to bring up the comments screen seem to take a long time. Is this just a factor of wordpress denormalized schema or is there another factor. The DB never seems to be overwhelmed other than this one spot.

  6. The answer there is you're too big for that limited a shared host if that's a problem -- 60+ images isn't that much at the end if a day. Still, WP can't give relative paths because not everyone installs WP the same way. Absolute paths ensures everyone works no matte how customized they are.

    There as db cache plugins for WP I think, but loading that many records us going to be sluggish :(

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.