Home / Forums / WoodMart support forum / PHP in Custom Tabs
Home › Forums › WoodMart support forum › PHP in Custom Tabs
PHP in Custom Tabs
- This topic has 2 replies, 2 voices, and was last updated 2 weeks, 5 days ago by
Artem Temos.
-
AuthorPosts
-
December 5, 2025 at 8:37 pm #699557
lucasszengParticipantHello,
I created a new Custom Tabs. Where can i find “Allow PHP in Custom Tabs”? Or how can i use PHP code in Custom Tabs?
Please help.Best regards
December 6, 2025 at 9:20 am #699597
lucasszengParticipantHello,
I hope you’re doing well.
My core requirement is to allow custom tabs to execute PHP code (displaying product attributes/ACF custom fields/static details in an accordion format). The website will expand to 5000+ products, requiring a batch upload tool. I didn’t use Elementor, worried it might slow down the website.
If executing PHP code is not allowed in custom tabs, can I add code to the child theme’s functions.php to force the parsing of PHP code in custom tabs?
The operation is as follows(paste the below code in functions.php)
// Force PHP code parsing in Woodmart 8.3.6 (no Advanced panel required)
add_filter(‘woodmart_get_custom_tab_content’, ‘wd_836_force_php_in_custom_tabs’, 99, 3);
function wd_836_force_php_in_custom_tabs($content, $tab, $product) {// Replace with the tab titles you created (exactly the same as those entered in the backend, case sensitive)
$allowed_tabs = array(‘Product Detail’, ‘Imprint’, ‘Production and Shipping’);// Only parse the specified tabs to avoid the security risk of globally executing PHP
if (in_array($tab[‘title’], $allowed_tabs) && !empty($content) && is_product()) {// Safely execute PHP code (only allow reading class functions, prohibit high-risk operations)
ob_start(); `eval(‘?>’ . $content);
$content = ob_get_clean();
}
return $content;
}Next, return to “Custom Tabs” and paste the PHP code directly into the Content input box.
Example:<p><strong>Theme:</strong> <?php the_field(‘theme’); ?></p>
<p><strong>Size:</strong> <?php the_field(‘size’); ?></p>
<p><strong>Unit Weight:</strong> <?php the_field(‘unit_weight’); ?></p>
<p><strong>Item Packaging:</strong> <?php the_field(‘item_packaging’); ?></p>
<p><strong>Safety and Compliance:</strong> <?php the_field(‘safety_compliance’); ?></p>
<p><strong>Color:</strong> <?php
$color_terms = `wp_get_post_terms(get_the_ID(), ‘pa_color’, array(‘fields’ => ‘names’, ‘number’ => 1));
echo $color_terms ? $color_terms[0] : ‘N/A’;
?></p>
<p>Material: <?php
$material_terms = wp_get_post_terms(get_the_ID(), ‘pa_material’, array(‘fields’ => ‘names’, ‘number’ => 1));
echo $material_terms ? $material_terms[0] : ‘N/A’;
?></p>Please help me verify if the above operation can achieve my core requirement.
Or if you have a better solution, please let me know. Thank you!Best regards
December 8, 2025 at 11:53 am #699785
Artem TemosKeymasterHello,
Our theme’s custom tabs feature doesn’t allow the use of PHP code. There’s no option for this at all. We recommend following the WooCommerce developers’ instructions on how to add your custom tab with any code. https://woocommerce.com/document/editing-product-data-tabs/#section-5
Kind Regards
-
AuthorPosts
Tagged: custom tabs
- You must be logged in to create new topics. Login / Register