Last active
May 4, 2016 17:21
-
-
Save claudioweb/23e95046f59d85e329c9ce716d28471d to your computer and use it in GitHub Desktop.
function para redirecionar templates e singles de um plugin para /templates
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
define( 'PLUGIN_PATH', plugin_dir_path(__FILE__)); | |
add_action('template_redirect', 'load_template_pluginname'); | |
function load_template_pluginname(){ | |
global $post; | |
if(get_post_meta($post->ID, 'pluginname_page', true)){ | |
if(locate_template('template-plugin-name.php', false) == ""){ | |
require_once PLUGIN_PATH . '/templates/template-plugin-name.php'; | |
die(); | |
} | |
} | |
if(is_singular('plugin-name')){ | |
if(locate_template('single-plugin-name.php', false) == ""){ | |
require_once PLUGIN_PATH . '/templates/single-plugin-name.php'; | |
die(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment