Woocommerce has it’s own function woocommerce_get_template_part() for loading template parts, use it like this:
woocommerce_get_template_part( $slug, $name );
which refers to the according file {$slug}-{$name}.php or used like this:
woocommerce_get_template_part( $slug );
refers to the file {$slug}.php, it automatically
Looks in yourtheme/slug(-name).php and yourtheme/woocommerce/slug(-name).php
it can be used with a conditional like this:
if( has_term( 'shop', 'product_cat' ) ) {
woocommerce_get_template_part( 'single-product-shop' );
} else {
woocommerce_get_template_part( 'content', 'single-product' );
}
Related Posts:
- How to export comments in WordPress?
- Overriding Plugin Template Files with Child Theme
- Load plugin on specific page only
- Does a plugin’s “main” file need to be named the same as the folder containing it?
- What causes the “Are you sure you want to do this?” error with plugins?
- Overwrite textdomain of plugins by default – Lost Translation
- Google Analytics post views in WordPress? [closed]
- scheduled event not getting executed
- How can I limit functionality in one version of a plugin?
- WordPress A-Z Navigation
- Any way to use a custom Parameter for youtube embed without using an iframe?
- Multi step form, custom plugin
- How do I prevent Plugin updates from clobbering user edits?
- Contact Form 7 plugin refreshing page on submit [closed]
- Some Plugin Settings Are Kept After Removal and Reinstall of the Plugin
- WordPress hook for visiting a post
- why does the add_action(‘the_content’) overwrite my page
- Fatal error: Class not found in
- Error Message from W3 Total Cache when .htaccess Rules Cannot Be Modified? [closed]
- Is it ok to call get_option without hooks?
- Send emails with wp_mail() using SMTP configured in plugin
- Show “Local Pickup” shipping method only for specific Woocommerce product categories [closed]
- What user roles should have wp_unique_post_slug_is_bad_flat_slug filter applied?
- Can I check plugins and themes for PHP 5.6 ahead of global PHP server Update
- How can I reuse the WordPress search form for a custom plugin / widget?
- Where should a plugin or widget cache its results?
- Set of plugins to control the Admin UI
- Do We Need to Validate, Sanitize, or Filter Simple Numerical Superglobals (Cookies and Post)?
- How to transfer all user data between wordpress installations?
- Appery.io and WordPress
- Plugin upgrade issue
- __callStatic method handler passed to add_action causes bug in PHP
- Multiple instances of nivo slider plugin
- New databes tables with – WooCommerce – for developers [closed]
- Interactive filters on wordpress [closed]
- Plugin-generated pages use Not Found or Pages Archive templates?
- Add padding while generating thumbnail
- Using TinyMCE in plugin?
- WordPress error: Options page Setting_ not found in the allowed options list
- flush_rewrite_rules() not working with update_option_{$option}
- PHP if statement with German umlauts [closed]
- How to ignore extra whitespaces in translation functions like _e?
- Can backlinks to my site increase my chances of plugin rejection
- Hide a certain category name from Related Posts
- Price comparison table based on Custom Post Type?
- wp_logout_url($redirect); is not working in wordpress
- The “Child Pages Shortcode” plugin, block template
- How do I determine if the user who registered is not spam?
- display unique post per category
- Is there a way to insert multiple images into a post at the same time without using a gallery?
- How to get a custom page through plugin?
- Filters on the_content with plugins, pages and shortcode
- Plugin to send messages to members/lists but not full-blown newsletters
- How to create a plugin page that shows XML?
- Plugin prevents code from working
- Determining Whether Automatic Upgrade will Fail?
- How to make WooCommerce payment method field optional?
- can’t install any wp plugins [duplicate]
- Show an admin menu item in Editor role
- Add Plugin broken after removing Booster for Woocommerce
- WP_CONTENT_DIR disables plugin directory
- WordPress Custom Hook with Class method
- WP Forms not displaying,becomming an fatal error
- Undefined index: custom_post_template_present
- Ensure WordPress Theme Uninstalls Completely
- Image path in childs theme
- one url for all pages
- Using foreach loop for `$instance` of form and update array widget iteration
- Mobile and Tablet responsive in Elementor but not on the actual site?
- WordPress backend post update without refresh
- Warning: sprintf(): Too few arguments in nav-menu-template.php
- how to insert thousands of posts faster?
- Redeclare a plugins function/class in my theme?
- RSS icons have the same Alt tag. Lighthouse is failing these elements. How do I display different alt tags for each icon?
- Coupon Codes for product discount combined with conditional free shipping
- Avoid enormous network payloads
- How to fix slow comment query?
- How to create a custom control in customizer
- Sanitize AROUND shortcode
- wp meta_query meta_value compare =REGEXP delimited by space
- Sending post data over REST API, how to parse shortcodes in post_content?
- Primary Menu doesn’t show because of w3 cache
- Create shared actions for admin and users with plugin bolierplate
- How to insert variable which contain array value in wp_options table?
- Plugin Screenshots not showing
- Wp Ecommerce Reposition Product Page Product Thumbnail Image
- It possible to implement an adhoc php web application with wordpress?
- Array to string conversion error when trying to POST multidimensional array
- How to test a WordPress plugin on a single post?
- WordPress Permission Problems on Ubuntu 12.04 with LAMP stack
- How to Overwrite validate_plugin function
- Plugin and javascript placement
- Disable plugin function
- Form data to wordpress DB
- Register additional wp plugin directory
- How to prevent page load on form submission
- Send email notification when meet the condition
- How to validate password length in wordpress
- URL Redirect on GoDaddy platform [closed]
- How to filter plugin search results in wp-admin plugin search page