Skip Navigation

[Resolved] Woocommerce: Different views on specific product ID or Category

This thread is resolved. Here is a description of the problem and solution.

Problem:
Woocommerce: Different views on specific product ID or Category

Solution:
You can use the view's filter wpv_filter_force_template to display different template per term or category.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/woocommerce-different-views-on-specific-product-id-or-category/#post-1082754

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_force_template

This support ticket is created 5 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1082678

Hello,
i'm on project on a site that using divi builder, toolset, woocommerce. Right now i'm able to create a global content template for CPT:Product. My question:
1. Is it possible to create different content template from specific post ID or category ?
2. Any tutorial on it ?

Thanks

#1082754

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - what if you try to use the view's filter wpv_filter_force_template

For example:

add_filter( 'wpv_filter_force_template', 'func_load_content_template_dynamically', 99, 3 );
function func_load_content_template_dynamically( $template_selected, $id, $kind ) {

    if ( $id == 999 ) { // if the user is  trying to view the post with ID 999
        $template_selected = 123; // assign a fixed Content Template with ID 123 when post with ID 999 is loaded
    }
    return $template_selected;
}

- You should try to adjust your above code as per your need.

More info:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_force_template

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.