简体   繁体   中英

WordPress - Ovveride plugin template in theme

I have plugin that create new post type. Also plugin set single template for it's single page.

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;
}

How i can override single-product.php in my theme.

I don't found any solutions for my question at this site.

just filter it a little later than the current function (ps if doing this within a class you need to reference it using array(&$this, 'function'). I left it out as i assume you are using the functions.php or function override....etc

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;

};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM