Skip to content

Instantly share code, notes, and snippets.

@EdwardBock
Last active July 22, 2021 20:25
Show Gist options
  • Save EdwardBock/9f3c8cf74e236d5ac38fc6312c36be01 to your computer and use it in GitHub Desktop.
Save EdwardBock/9f3c8cf74e236d5ac38fc6312c36be01 to your computer and use it in GitHub Desktop.
Locate theme template path
<?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