Skip to content

Instantly share code, notes, and snippets.

@EdwardBock
Last active July 22, 2021 14:11
Show Gist options
  • Save EdwardBock/8c1f2793dc03fee4112d6e7ffcd58dad to your computer and use it in GitHub Desktop.
Save EdwardBock/8c1f2793dc03fee4112d6e7ffcd58dad to your computer and use it in GitHub Desktop.
Parent theme template path
<?php
namespace PublicFunctionOrg\WordPress;
class Templates {
private $theme_dir = "/my-plugin-templates/";
public function get_template_path($template){
$path = $this->theme_dir.$template;
if( is_file( get_template_directory().$path)){
return get_template_directory().$path;
}
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