[resolved] Outputting stylesheet uri in a function (8 posts)

  1. iand
    Posted 9 years ago #

    For a theme specific function I need to create a path to the stylesheet directory.
    The Codex Page suggests that echo '<img src="' . get_settings('stylesheet_directory') . ''; will work but as far as I can tell, of the 'will work with 1.5+' options, only 'html_type' generates anything.

    At the moment I am using this within my function:
    echo '<img src="' . get_settings('siteurl') . '/pathto/stylesheet/directory>'; which is not going to be good if the theme folder is renamed.

    Any help/ suggestions would be appreciated, this is my first foray into coding and I am out of ideas.

  2. James Huff
    Volunteer Moderator
    Posted 9 years ago #


    <?php bloginfo('stylesheet_directory'); ?>


  3. If you want output on screen, you need bloginfo(), not get_bloginfo()


    <?php bloginfo('stylesheet_url')?> should be what you need.

    EDIT: must work quicker :)

  4. iand
    Posted 9 years ago #

    Thanks both. However, I am not after output on screen though, I am after output into a function and that will output on screen:
    value of stylesheet uri -> myfunction -> screen output

  5. In which case, get_bloginfo should work nicely:

    $ss_directory = get_bloginfo('stylesheet_directory');
    echo $ss_directory;
    <img src="<?php echo $ss_directory?>/validcss.gif" />
    <img src="<?php echo bloginfo('stylesheet_directory');?>/validcss.gif" />

    All work....

    Works for me.

  6. iand
    Posted 9 years ago #

    The function is question is here. At the moment I am defining $imagepath by hand and using get_settings('siteurl') . ''.$imagepath.'/ as an alternative.

  7. And what happens if you use get_bloginfo('stylesheet_directory') ?

  8. iand
    Posted 9 years ago #

    I was just doing that - using $ss_directory = get_bloginfo('stylesheet_directory'); worked perfectly. Thanks a lot.

Topic Closed

This topic has been closed to new replies.

About this Topic