templatepath (5 posts)

  1. AndWat
    Posted 11 years ago #

    The codex states that: "The constant TEMPLATEPATH is a reference to the absolute path to the current theme directory."

    I don't think that the codex is correct here. I think that TEMPLATEPATH points to the current template directory. This will differ from the theme directory if the theme in question specifies a parent theme. For example, one of my themes, TheGatesWay, includes in its header the line:
    So winterway is the parent theme, and the template (i.e. the .php files) is inherited from it.

    TEMPLATEPATH correctly refers to the directory winterway. It does not refer to the directory in which TheGatesWay's style.css lives, and nor should it.

    It would be nice if there was another constant, THEMEPATH, that did refer to the current theme directory. Yes, one can get to this using bloginfo(’stylesheet_directory’). But a predefined constant for the theme, similar to the one for the template, would be neat and symmetrical.

    To summarize: I've pointed to what I think is a minor error in the codex; and I've requested that future versions of WP include a new constant. To conclude: sorry to have been so long-winded about this.

  2. Root
    Posted 11 years ago #

    Its a bloginfo parameter already surely?

  3. Ryan Boren
    WordPress Dev
    Posted 11 years ago #

    Codex updated. There is not currently a constant defined for it, but you can get the theme/stylesheet path with get_stylesheet_directory().

  4. Ryan Boren
    WordPress Dev
    Posted 11 years ago #

    Yes, you can use bloginfo('stylesheet_directory') too.

  5. Root
    Posted 11 years ago #

    And there is a template path as well.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.