Shortcode
[smart_product_gallery]puts a product's gallery anywhere that runs shortcodes: a page builder template, a landing page, a widget area.
Syntax
[smart_product_gallery]
[smart_product_gallery product_id="123"]| Attribute | What it does | Default |
|---|---|---|
product_id | The FluentCart product whose gallery to show. | The current post. On a product page or in a product template, that's the product being viewed. |
That's the only attribute. Everything else, including layout, zoom, lightbox and colors, comes from your global settings at FluentCart → Product Gallery. That way, every gallery on your site stays consistent. You can't, for example, give one shortcode a different layout from the rest.
You can copy the shortcode from Advanced → Advanced Controls in the settings. See Advanced.
When to use it
On a classic theme you usually don't need it: the gallery replaces FluentCart's own on every product page automatically. Use the shortcode when:
- You've designed the product page in a page builder. Elementor, Divi, Bricks, Oxygen and others can build their own single-product template. Add the builder's Shortcode element where the gallery should go and paste
[smart_product_gallery]with noproduct_id. It picks up whichever product is being viewed. Step-by-step guides: Elementor, Divi, Bricks, Oxygen. - You want a product's gallery somewhere else, such as a landing page, a blog post reviewing the product, or a "product of the month" section. Use
product_id.
On a block theme, use the Product Gallery block in the Single Product template instead. It does the same job without the shortcode.
Finding a product's ID
- Go to FluentCart → Products and open the product.
- Look at your browser's address bar. The address ends in something like
#/products/123/pricing, and the number after/products/is the ID.
It loads its own scripts and styles
Normally the gallery's CSS and JavaScript only load on FluentCart product, shop and category pages, to keep the rest of your site lean. The shortcode loads them itself wherever it's used, so a gallery on an ordinary page works fully: slider, zoom, lightbox and your Additional CSS.
Messages you might see
| Output | Cause |
|---|---|
| "Please provide a valid product ID." | There's no product_id and the page has no current post. This happens in some widget areas and builder previews. Add product_id="…". |
| "No images found for this product." | The product has no featured image, gallery images or variation images. Add images to the product in FluentCart. |
In page-builder previews
Some builders render shortcodes in their editor without loading the front-end scripts. The gallery may look like a stack of plain images while you edit. That's expected: preview or view the live page to see it working.
Using it in PHP
To output the gallery from a theme template file, run the shortcode through do_shortcode():
<?php echo do_shortcode( '[smart_product_gallery]' ); ?>Inside the product loop this uses the current product. Elsewhere, pass the ID:
<?php echo do_shortcode( '[smart_product_gallery product_id="' . absint( $product_id ) . '"]' ); ?>Where to go next
- Gutenberg Block: the block-editor equivalent.
- Custom CSS Reference: style the output.
- How It Works: when the gallery appears on its own and when it doesn't.