WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. iand
    Member
    Posted 8 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. Try:

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

    http://codex.wordpress.org/Template_Tags/bloginfo

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

    http://codex.wordpress.org/Template_Tags/bloginfo

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

    EDIT: must work quicker :)

  4. iand
    Member
    Posted 8 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:

    <?php
    $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
    Member
    Posted 8 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
    Member
    Posted 8 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