WordPress.org

Ready to get started?Download WordPress

Forums

Placeholder for the stylesheet directory (5 posts)

  1. Lulio Sr.
    Member
    Posted 2 years ago #

    Hi WordPress,

    The default twentyeleven theme function calls register_default_headers() using "%s" as a placeholder in the template directory.

    If I wanted to store my custom header images in my child theme, i would need to refer to the stylesheet directory. What would be the correct placeholder for the stylesheet directory?

    Thank you

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    You shouldn't need to do anything. The code in the parent will automatically look in the same folder in the child theme.

  3. Lulio Sr.
    Member
    Posted 2 years ago #

    esmi,

    I'm sorry, but I don't quite understand your answer.

    Let me rephrase my question. I'm not using twentyeleven as my parent theme. My parent theme doesn't have support for custom headers. To make it simple, say I want to add the custom headers feature to my child theme by borrowing code from twentyten's functions.php file:

    `// No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
    if ( ! defined( 'HEADER_IMAGE' ) )
    define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );`

    My question is about the %s placeholder. It prints the template directory; meaning, the parent's theme directory URI. Is there a placeholder that would print the child's theme directory URI (Known in WordPress as the stylesheet directory) instead?

    Thanks for your help, Lulio

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    If you are just adding this to the child theme, you don't need %s. Just try using get_stylesheet_directory_uri.

  5. Lulio Sr.
    Member
    Posted 2 years ago #

    esmi,

    In practice, that works fine.

    I was just curious about the existence of a placeholder for the stylesheet directory. I think the answer comes from wp-includes/themes.php. However, that would be "above my pay grade"; I'm a plain web designer.

    Thanks esmi.

Topic Closed

This topic has been closed to new replies.

About this Topic