WooCommerce – Add a tab to the product page
-
Hey everyone,
Thought I’d share this snippet – while I’m building TWP I wanted to share our Plugin’s changelog and current version, so I need to add a tab to the WooCommerce page with that info.
Here’s the snippet I used:
// Add custom product tab add_filter( 'woocommerce_product_tabs', 'custom_product_tab' ); function custom_product_tab( $tabs ) { $tabs['custom_tab'] = array( 'title' => __( 'Custom Tab', 'woocommerce' ), 'priority' => 50, 'callback' => 'custom_tab_content' ); return $tabs; } // Custom tab content function custom_tab_content() { global $post; $custom_field = get_post_meta( $post->ID, 'custom_field', true ); echo '<h2>Custom Tab</h2>'; echo '<p>' . $custom_field . '</p>'; }
Cheers,
Aron
- You must be logged in to reply to this topic.