Vov4eg
Vov4eg

Reputation: 13

Why TEMPLATEPATH return absolute path to child directory?

I am using framework for develop theme for wordpress. after install framework i create child theme and include files from my framework in functions.php.

In 2 other projects all works fine, but in my new project i have an error. When i call TEMPLATEPATH it back absolute path to child directory, but it must return a path to parent theme.

What can be wrong?

P.S. Framework use TEMPLATEPATH to include his own files, so i need to understand how can i fix this problem.

Upvotes: 0

Views: 1444

Answers (3)

Justin Carlson
Justin Carlson

Reputation: 2710

This happened to me because I created my child theme first and had it activated BEFORE creating my parent themes style.css file.

All you have to do to fix this is Activate any other theme, then reactivate your child theme. This will correct the 'template' value in the wp_options table.

Upvotes: 0

Vov4eg
Vov4eg

Reputation: 13

I found solution of my problem.
I got wrong path to parent theme because in DB in table "wp_options" in field "template" was a child theme name. When i changed value of this field to parent theme name, the TEMPLATEPATH start return a path to parent theme.

Upvotes: 1

user2019515
user2019515

Reputation: 4503

You should try using get_template_directory_uri() to get the parent theme directory like so:

 echo get_template_directory_uri()/img/icon.png

If you want to get something out of your child theme directory you can use get_stylesheet_directory_uri().

More info:

Edit: Just noticed McNab's reply in the comments of the question, give this guy some upvotes as well. :)

Upvotes: 1

Related Questions