[英]WordPress - Ovveride plugin template in theme
我有创建新帖子类型的插件。 插件还为其单个页面设置了单个模板。
add_filter( 'single_template', array( &$this, 'register_ipa_product_post_type_single_template' ) );
function register_ipa_product_post_type_single_template( $single_template ) {
global $post;
if ( $post->post_type == 'product' ) {
$single_template = IPA_PRODUCT_POST_TYPE_TEMPLATE_FOLDER . 'single-product.php';
}
return $single_template;
}
我如何在主题中覆盖single-product.php。
在此站点上找不到我的问题的任何解决方案。
只是比当前函数晚一点过滤(ps,如果在类中执行此操作,则需要使用array(&$ this,'function')对其进行引用。由于我假设您正在使用functions.php或功能覆盖...等
add_filter( 'single_template', 'register_ipa_product_post_type_single_template', 100 );
function change_temp( $single_template ) {
global $post;
if ( $post->post_type == 'product' ) {
$single_template = 'path to your template file';
}
return $single_template;
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.