Title: Code to add within description
Last modified: May 7, 2018

---

# Code to add within description

 *  Resolved [Erika Jones-Clary](https://wordpress.org/support/users/agrohippy/)
 * (@agrohippy)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/code-to-add-within-description/)
 * Greetings! I suspect this plugin will be perfect for my client needs. Currently
   the custom tabs do not show on my product pages however I suspect it’s because
   I’m using a theme that already has its own tabs.
 * I really want to insert the custom tab within the product description. Can you
   guide me with some code? Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/)
 * (@yikesitskevin)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/code-to-add-within-description/#post-10258096)
 * Hi [@agrohippy](https://wordpress.org/support/users/agrohippy/),
 * I’m not quite sure what you’re looking for so if I misunderstood you please clarify.
 * A few people recently asked for a shortcode to use with Custom Product Tabs. 
   This is not part of the plugin but we developed one that folks can use. Add this
   code to your site (let me know if you need assistance with that) and then use`[
   custom_product_tabs]` within your description. By default, it will show all of
   our YIKES Custom Product Tabs with no real layout. However, this might be what
   you’re looking for.
 *     ```
       function yikes_custom_product_tabs_shortcode( $args ) {
       	global $post;
   
       	// Define our default values
       	$defaults = array(
       		'product_id' => $post->ID,
       		'tab_number' => 'all',
       	);
   
       	// Let the user-defined values override our defaults
       	$values = is_array( $args ) ? array_merge( $defaults, $args ) : $defaults;
   
       	// Make sure we have a product ID and that the product ID is for a product 
       	if ( empty( $values['product_id'] ) || ! empty( $values['product_id'] ) && get_post_type( $values['product_id'] ) !== 'product' ) {
       		return;
       	}
   
       	// Fetch our tabs
       	$tabs = get_post_meta( $values['product_id'], 'yikes_woo_products_tabs', true );
   
       	// Get just the specified tab. (minus tab number by one so it starts at 0)
       	$tabs = absint( $values['tab_number'] ) < 1 ? $tabs : ( isset( $tabs[ absint( $values['tab_number'] ) - 1 ] ) ? array( $tabs[ absint( $values['tab_number'] ) - 1 ] ) : array() );
   
       	if ( empty( $tabs ) ) {
       		return;
       	}
   
       	// Debug statement to show all tab data. Feel free to remove.
       	// echo '<pre>'; var_dump( $tabs ); echo '</pre>';
   
       	$html = '';
   
       	// Loop through the tabs and display each one
       	foreach( $tabs as $tab ) {
       		$html .= '<p>' . $tab['title'] . '</p>';
       		$html .= '<p>' . $tab['content'] . '</p>';
       	}
   
       	// Make sure to return your content, do not echo it.
       	return $html;
       }
   
       add_shortcode( 'custom_product_tabs', 'yikes_custom_product_tabs_shortcode' );
       ```
   
 * Let me know.
 * Cheers,
    Kevin.
 *  Thread Starter [Erika Jones-Clary](https://wordpress.org/support/users/agrohippy/)
 * (@agrohippy)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/code-to-add-within-description/#post-10260071)
 * This was perfect thank you. I was able to echo the shortcode so I could add the
   tab information within my product description. Appreciate the quick reply.
 *  Plugin Contributor [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/)
 * (@yikesitskevin)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/code-to-add-within-description/#post-10260081)
 * Awesome! I’m glad that worked for you.
 * Cheers,
    Kevin.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Code to add within description’ is closed to new replies.

 * ![](https://ps.w.org/yikes-inc-easy-custom-woocommerce-product-tabs/assets/icon-
   256x256.png?rev=1558461)
 * [Custom Product Tabs for WooCommerce](https://wordpress.org/plugins/yikes-inc-easy-custom-woocommerce-product-tabs/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yikes-inc-easy-custom-woocommerce-product-tabs/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs/)
 * [Active Topics](https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/code-to-add-within-description/#post-10260081)
 * Status: resolved