用template_include钩子在插件里重写默认模板
Published
2023-03-02
浏览次数 : 106
function myplugin_author_template( $template ) {
if ( is_author() ) {
// Path to your custom template file in your plugin directory
$custom_template = plugin_dir_path( __FILE__ ) . 'templates/my-author-template.php';
// If your custom template file exists, use it instead of the default author.php template
if ( file_exists( $custom_template ) ) {
$template = $custom_template;
}
}
return $template;
}
add_filter( 'template_include', 'myplugin_author_template' );
- 标签1
- 标签1
- 标签1