Hi @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.