Support » Plugin: WP Bootstrap Carousel » Woocommerce Product Gallery

  • Resolved bountydigital

    (@bounty_digital)


    Is it possible to get the plugin to pull images from the product gallery instead of whatever has been attached to the product page? That way it would be easier to arrange the order in which they appear in the slider.

    Also having slight problem removing the image links, I’ve used these settings but it’s still linking to the attachment image page:
    [carousel thickbox=”0″ unwrap=”0″ file=”0″]

    https://wordpress.org/plugins/wp-bootstrap-carousel/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Peter J. Herrel

    (@donutz)

    @bounty_digital, sure, but I’m afraid you’ll have to use the Display Posts Shortcode addon for that. Below is a snippet you could tweak to your liking. The code should go in your functions.php or in a custom plugin, and will append a carousel with product gallery images to the post content:

    add_filter( 'the_content', 'wpbc_woo_the_content', 10, 1 );
    function wpbc_woo_the_content( $content )
    {
        if( ! is_singular( 'product' ) )
            return $content;
    
        global $product;
    
        $wpbc_attachment_ids = $product->get_gallery_attachment_ids();
    
        if( $wpbc_attachment_ids )
        {
            $wpbc_attachment_ids = implode( ',', $wpbc_attachment_ids );
    
            $content = $content . do_shortcode( '[display-posts post_type="attachment" id="' . $wpbc_attachment_ids . '" bootstrap="1" unwrap="1"]' );
        }
    
        return $content;
    }

    As to your second question, a simple unwrap="1" should do the trick. However, you might be experiencing a problem similar to this one.

    Hey! Thanks for your quick reply. Unfortunately it’s not working for me. It doesnt output the carousel. It just prints the shortcode. 🙁

    Plugin Author Peter J. Herrel

    (@donutz)

    You’ll need to install the Display Posts Shortcode plugin: https://wordpress.org/plugins/display-posts-shortcode/

    Silly me! Thanks!!

    Is there a way to order it in the order you’ve set in the product gallery?
    Also there seems to be loading issues if you use the ‘display posts’ shortcode. The carousel shows the first image but leaves a grey space underneath (size depends on how many images in carousel)… Once you refresh it works normally though.

    Plugin Author Peter J. Herrel

    (@donutz)

    @bounty_digital I tweaked the snippet a little. Using post__in for the orderby param, the carousel will respect the order of the images in the product gallery:

    add_filter( 'the_content', 'wpbc_woo_the_content', 10, 1 );
    function wpbc_woo_the_content( $content )
    {
        if( ! is_singular( 'product' ) )
            return $content;
    
        global $product;
    
        if( $product->get_gallery_attachment_ids() )
        {
            $content = $content . do_shortcode( '[display-posts orderby="post__in" post_type="attachment" id="' . get_post_meta( $product->post->ID, '_product_image_gallery', true ) . '" bootstrap="1" unwrap="1"]' );
        }
    
        return $content;
    }

    About the grey space, sounds like a rather specific issue, but I might be wrong. Are you using a Bootstrap powered theme?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Woocommerce Product Gallery’ is closed to new replies.