Forums

Get theme relative link, not absolute (no http!) (3 posts)

  1. scotchegg78
    Member
    Posted 1 month ago #

    Hey guys

    At the moment i use bloginfo('template_directory');?>/img/mail.gif

    which of course works and outputs...
    src="http://localhost/newsite/wp-content/themes/scotchegg/img/mail.gif"

    however here is the issue, i am want to test this from other machines on the network, and also a VM running IE6. In this case http://localhost will cause it to fail. So what I want is to get a pure relative link from index returned. so the output would be and used as..

    src="wp-content/themes/scotchegg/img/mail.gif"

    Is there a WP function already to get this?

    thanks

  2. scotchegg78
    Member
    Posted 1 month ago #

    ive just played with editing general-template.php in WP core.

    added ..

    case 'rel_template_directory':
    		case 'rel_template_url':
    			$output = wp_make_link_relative(get_template_directory_uri());

    this is a solution i guess, but would of rathered there been something in WP as default moving forward, or even the option make links relative, absolute in the backend.

  3. jdembowski
    Member
    Posted 1 month ago #

    If that's part of a function (I have not looked yet) it might be safer to put that modification into your theme's function.php file.

    Easier to keep your own functions up to date than mess with the core files.

    Edit: DOH, it's bloginfo() just as you said already...

Reply

You must log in to post.

About this Topic