This code works with the Smart bundle from the WPC Product Bundles for WooCommerce plugin.
It is a shortcode that gets the current product bundles thumbnails and links.
If the Title is true it only gets the text list that’s it.
[show_woosb_thumbnails]
[show_woosb_thumbnails title=”true”]
You can use it inside the loop like this for example and I added data-balloon attributes it works great with bricks builder 🙂
// [show_woosb_thumbnails title="true"] // function display_woosb_ids_thumbnails($atts) { global $post; $atts = shortcode_atts( array( 'title' => 'false', ), $atts, 'show_woosb_thumbnails' ); $woosb_ids = get_post_meta($post->ID, 'woosb_ids', true); $output = ''; // Check if woosb_ids is an array if (is_array($woosb_ids)) { // Loop through each item in the woosb_ids array foreach ($woosb_ids as $item) { // Check if 'id' exists and is valid if (isset($item['id']) && is_numeric($item['id'])) { // Get the post title for the given post ID $post_title = get_the_title($item['id']); // Check if 'title' attribute is set to 'true' if ($atts['title'] === 'true') { // Append only the post title to the output $output .= '<p>' . esc_html($post_title) . '</p>'; } else { // Get the thumbnail URL and permalink for the given post ID $thumbnail_url = get_the_post_thumbnail_url($item['id'], 'thumbnail'); $permalink = get_permalink($item['id']); // Append the thumbnail as a linked <img> tag with an alt title to the output if ($thumbnail_url) { $output .= '<a href="' . esc_url($permalink) . '" data-balloon="' . esc_attr($post_title) . '" data-balloon-pos="top" > '; $output .= '<img src="' . esc_url($thumbnail_url) . '" alt="' . esc_attr($post_title) . '" class="bundle-thumbnail" >'; $output .= '</a>'; } else { // If no thumbnail, provide a fallback message or image $output .= '<p>No thumbnail available for post ID: ' . $item['id'] . '</p>'; } } } } } else { $output .= '<p>No woosb_ids found or it is not an array.</p>'; } // Return the final output (either titles only or thumbnails with links) return $output; } add_shortcode('show_woosb_thumbnails', 'display_woosb_ids_thumbnails');