Last active
July 22, 2021 20:25
-
-
Save EdwardBock/9f3c8cf74e236d5ac38fc6312c36be01 to your computer and use it in GitHub Desktop.
Locate theme template path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PublicFunctionOrg\WordPress; | |
class Templates { | |
private $theme_dir = "/my-plugin-templates/"; | |
public function get_template_path($template){ | |
if ( $overridden_template = locate_template( $this->theme_dir.$template ) ) { | |
return $overridden_template; | |
} | |
return false; | |
} | |
} | |
$templates = new Templates(); | |
$filepath = $templates->get_template_path("my-template.php"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment