• Hi what is the code that will add an absolute path to images, links etc…

    For instance if I want to put a path like this
    <img src=”https://www.mysite.com/images/logo.png&#8221; >

    is there a tag like this to put in?
    <img src=”<?php bloginfo(‘url’);?>/images/logo.png” >

    also if there was a tag to call that where would I put the / in. thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Try:

    <img src="https://
    
    <?php
    echo $_SERVER['SERVER_NAME'];
    ?>
    
    /images/logo.png">

    This is a standard PHP function, not a WordPress one.

    If you use this a lot, you can shorten it by assigning it to a variable:

    $add = "<img src=\"https://" . $_SERVER['SERVER_NAME'] . "/images/";

    Your original code would then be:

    <?php echo $add; ?>
    logo.png">
    Thread Starter kvnmcwebn

    (@kvnmcwebn)

    hi, where would I put that variable?
    in the functions.php file?
    thanks a million.

    You can put it in the functions file (use a child theme if you aren’t a theme designer).

    Thread Starter kvnmcwebn

    (@kvnmcwebn)

    Cool. Thanks. I’m creating a custom theme but I’m using the functions.php file from twentyten. I hope that’s not too sloppy…

    Well…you really should only include the functions that you actually need/use.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘how to add an absolute path to static elements’ is closed to new replies.