Forums

Can bloginfo be used to make a relative link? (4 posts)

  1. keress
    Member
    Posted 2 years ago #

    I want to call up another stylesheet in my template and have been playing with the bloginfo code to see if it will let me write in another one in my header.php without using a hard link.

    I've tried:

    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory')/navigation.css; ?>" />

    but it just outputs the directory, ignoring the '/navigation.css" bit. Is there a way to do this?

    Thanks

  2. jceresini
    Member
    Posted 2 years ago #

    Relative links will be problematic if you are using permalinks. For example if you have

    blog.domain.com/post/1 and you try to make a link to "wp-content/themes/yourtheme/stylesheet.css" the browser will try to load "[website_directory]/post/wp-content/themes/yourtheme/stylesheet.css".

    Is there any reason you're trying to use relative links? Or did I misunderstand your question?

  3. keress
    Member
    Posted 2 years ago #

    I'm just trying to use it for the usual reason, if there's a change at some point in the url, the link won't need to be changed.

  4. keress
    Member
    Posted 2 years ago #

    Hmm. I'm not seeing that. I have this line in my header.php

    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory')/navigation.css; ?>" />

    and it's producing this:

    <link rel="stylesheet" type="text/css" href="http://www.hearingsolutionstriangle.com/wp-content/themes/hearwell" />

    If I can just get it to add the "navigation.css" bit I'll have what I want.

    I thought the conventional wisdom was that we are 'supposed' to use relative links as much as possible.

Topic Closed

This topic has been closed to new replies.

About this Topic