Ivan Milic - Networks expert Ivan Milic CEO Ivan Milic

Top Menu

× To post a question you must be signed in.

excel like: template page

03 Feb 2018 20:02 #2857 by hashem
excel like: template page was created by hashem
hi
I want to know is it possible to use a column to chose as a template of single product page and how is it possible.
thank you

Please Log in or Create an account to join the conversation.

05 Feb 2018 12:15 #2858 by Super User
Replied by Super User on topic excel like: template page
In wooCommerce by default products don't have a option of choosing specific display template for them.
You can certainly manage some meta property or taxonomy you can use in code to load template but you have to code that.

Define simple custom meta field "template_override".
For products with override enter name of file without extension.
For this example that file should be in same directory as singe-product.php
Code example:
$pid = get_the_ID();
$template = get_post_meta( $pid,'template_override', true );
if( $template ) {
    $file = "$template.php";
    global $woocommerce;
    load_template( $woocommerce->template_url . $file );
    return;
} 

Please Log in or Create an account to join the conversation.

Time to create page: 0.102 seconds