WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to get the folder with the theme? (3 posts)

  1. hategrinder
    Member
    Posted 6 years ago #

    Hello! I'm writing a plugin that is going to modify template files when switching to it, so I need to know, in which folder template files are. I tried to use switch_theme action , but it gives only the name of the theme, whilst the folder can named the other way. For example if the theme name, given by action, is 'The Theme', folder can be 'the_theme', 'thetheme', 'the-theme', 'the-theme-10', 'TheTheme' ... Is there any way to get the folder, template is in? TIA

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    The constant TEMPLATEPATH is a reference to the absolute path to the template directory for the current Theme (without the / at the end).

    You can also use get_template_directory(), but the constant is simpler.

  3. hategrinder
    Member
    Posted 6 years ago #

    Otto42, thanks! Hovewer in this case TEMPLATEPATH won't work, probably because this constant is redefined after the theme is changed and switch_theme is executed before, so it returns the path to current template, but get_template_directory() returns the new path to template and that's cool:) Thanks once again)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags