I have the following file structure (simplified):
— app
— header.php
- views
- header-default.php
In header.php, I'm using get_template_part
as follows:
<?php get_template_part( 'app/views/header/header', 'default' ); ?>
This works, but suppose in the future I need to change my folder structure or simply rename the "app" folder. It won't work anymore. How do I make get_template_part
always relative to the file I'm using it in? I tried:
<?php get_template_part( __DIR__ . '/views/header/header', 'default' ); ?>
but it's not working. I guess Wordpress always uses the root directory as a starting point to interpret the path. What options do I have?