Title: Shortcode for tabs
Last modified: September 13, 2021

---

# Shortcode for tabs

 *  [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * (@binarywc)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/)
 * We have a few tabs using the free version of this plugin that we sometimes want
   to pull the content for use in another page of the website without needing to
   remember everywhere we placed that products info.
 * Is it possible to pull the data from our custom tabs using a short code?
 * Thank you in advance.

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

 *  [jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * (@jpowersdev)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-14867024)
 * Hi [@binarywc](https://wordpress.org/support/users/binarywc/),
 * You can use shortcodes in the content of your tabs, so my recommendation would
   be to define a shortcode separately and use it in your tab’s content and any 
   other needed location.
 * You could also theoretically write a shortcode to pull specific tab data from
   your products, but you would need to know the product’s ID and the title of tab
   at minimum. Then you could use a strategy like this:
 *     ```
       $tabs = get_post_meta($product_id, 'yikes_woo_products_tabs', true);
   
       $tab = array_filter($tabs, function($tab){
         return 'my-title' === $tab['title'];
       });
       ```
   
 * to fetch the tab data for that product in the body of a shortcode function.
 * Option one would be much easier unless you have a specific reason for needing
   the tab defined on the product.
 * Let me know if that helps,
    Jon
    -  This reply was modified 4 years, 9 months ago by [jpowersdev](https://wordpress.org/support/users/jpowersdev/).
    -  This reply was modified 4 years, 9 months ago by [jpowersdev](https://wordpress.org/support/users/jpowersdev/).
 *  Thread Starter [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * (@binarywc)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-14867313)
 * Option one would not work because there are 40+ products that all have different
   content in the description and custom tabs we’ve added and we want to put the
   info in the woocommerce database directly so it is easy to update it.
 * I will try the second option later today and reply again if I need more assistance
   but I think that will not do precisely what I am looking for based on what I 
   used to create a short code for the default description tab.
 *  Thread Starter [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * (@binarywc)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-14875817)
 * Hi, Does the second method you suggested require that the tabs are universal 
   tabs that are added in the “Saved Tabs” screen?
 * Please let me know.
 *  Thread Starter [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * (@binarywc)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-14885895)
 * [@jpowersdev](https://wordpress.org/support/users/jpowersdev/) Did you see my
   question from a few days ago?
 *  [jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * (@jpowersdev)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-14890414)
 * Hi [@binarywc](https://wordpress.org/support/users/binarywc/),
 * Sorry, I was out last week.
 * No, it does not require that they are universal tabs. Did you run into issues?
 * Jon
 *  Thread Starter [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * (@binarywc)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-14891049)
 * I would not necessarily say I ran into issues except that the code was not working
   when I created the short it was returning nothing from the tab we were using.
   I will play around with it a bit more and update you with my exact code in the
   next couple days. Thanks for your reply to my question.
 *  [jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * (@jpowersdev)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-15003287)
 * Hi [@binarywc](https://wordpress.org/support/users/binarywc/),
 * Just checking in, are you still having trouble or were you able to figure it 
   out?
 * Jon
 *  Thread Starter [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * (@binarywc)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-15005899)
 * Nope. When I created the shortcode it was not returning the content at all. I
   have still been digging for a solution but haven’t come up with one yet.
 *  Thread Starter [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * (@binarywc)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-15108215)
 * [@jpowersdev](https://wordpress.org/support/users/jpowersdev/) I believe the 
   problems I’m running into relate to my shortcode also needing the product id…
   The problem with this is I’m not farm iOS familiar with the code from your plugin
   so I’m not sure if I’d need a different hook or filter than the default ones 
   offered by Woocommerce. Would you mind clarifying that for me? Thank you in advance
   in advance!
 *  [jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * (@jpowersdev)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-15118190)
 * Hi [@binarywc](https://wordpress.org/support/users/binarywc/),
 * Could you post the full code snippet here so I can take a look?
 * Thanks,
    Jon
 *  Thread Starter [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * (@binarywc)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-15118330)
 * [@jpowersdev](https://wordpress.org/support/users/jpowersdev/) I have tried too
   many code snippets to count with no luck! None of the snippets returned and content
   when I used the short code. Like I said in my last post i think the product id
   is needed and I’m not familiar with the code from your plugin so I’m not sure
   if I’d need a different hook or filter than the default ones offered by Woocommerce!
 *  [jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * (@jpowersdev)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-15118366)
 * Hi [@binarywc](https://wordpress.org/support/users/binarywc/),
 * In the case of the product ID – Since this shortcode is only running in tabs 
   on a single product page, `get_the_ID()` should return the ID of the current 
   product. That’s a core [WordPress function](https://developer.wordpress.org/reference/functions/get_the_id/)
   you can use here because we’re in [The Loop](https://codex.wordpress.org/The_Loop).
 * Once you grab the meta value for the tabs (using the product ID), you can use
   something like [print_r](https://www.php.net/manual/en/function.print-r.php) 
   or [var_dump](https://www.php.net/manual/es/function.var-dump.php) to see the
   shape of that data so you can determine what you need. My little [array_filter](https://www.php.net/manual/en/function.array-filter.php)
   snippet is looping through the list of tabs and picking out the one with a matching
   title. That way you can check to see if it exists.
 * Let me know if that helps,
    Jon
 *  Thread Starter [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * (@binarywc)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-15119462)
 * [@jpowersdev](https://wordpress.org/support/users/jpowersdev/) No, that does 
   not really help because I have not had time to familiarize my self with the code
   in the Custom Product Tabs for WooCommerce plugin and the problem is that what
   you told me to use for the short code is returning literally nothing, not even
   an error… no matter what I’ve done in my 12-15 tests.
 * However, I realized that I was saying
 * >  I’m not sure if I’d need a different hook or filter than the default ones 
   > offered by Woocommerce!
 * I really mean I’m not sure if I’d need a different hook or filter than the default
   ones offered by WordPress!
 * Would you please provide me a sample short code function based on your plugin
   that will return the content/copy of one single tab. I will then be able to understand
   what I misunderstood from your post a few weeks ago.
 * Thank you in advance.

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

The topic ‘Shortcode for tabs’ 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/)

 * 13 replies
 * 2 participants
 * Last reply from: [Davood Denavi](https://wordpress.org/support/users/binarywc/)
 * Last activity: [4 years, 6 months ago](https://wordpress.org/support/topic/shortcode-for-tabs/#post-15119462)
 * Status: not resolved