Shortcodes reference
Available Shortcodes
Free Downloads for WooCommerce includes shortcodes that let you display download buttons and forms anywhere on your site. This guide covers all available shortcodes and their usage.
[download_now] - Download Link
Inserts a download button or link for a product. You can use it with or without a product ID: without id it uses the current product (ideal on product pages and in theme or page builder product templates); with id it shows the button for that product anywhere on your site.
Basic Usage:
On a product page or in a theme builder product template (no ID needed):
[download_now]
For a specific product anywhere (e.g. sidebar, landing page):
[download_now id="99"]
Full Syntax:
[download_now id="99" text="Get it Free!" align="center"]
Parameters:
| Parameter | Required | Default | Description |
|---|---|---|---|
id | No | Current product | Product ID. Omit on product pages or in product templates to use the current product. |
text | No | "Download Now" | Custom button text |
align | No | left | Alignment: left, center, or right |
Examples:
[download_now]
On a product page or in a theme/page builder product layout, displays the download button for that product. No ID needed.
[download_now id="123"]
Displays download button for product ID 123 with default text and left alignment.
[download_now id="456" text="Get Your Free eBook"]
Custom button text.
[download_now id="789" align="center"]
Center-aligned button.
[download_now id="101" text="Download PDF" align="right"]
Custom text and right alignment.
Notes:
- This is a block-level element (displays on its own line)
- Cannot be placed inline with text or images
- If product is not valid for free download, nothing is displayed
- Works with single and multiple file products
[download_now_page] - Download Form
Displays the complete download interface as it appears on a product page. Useful for custom product pages or landing pages.
Basic Usage:
[download_now_page id="99"]
Full Syntax:
[download_now_page id="99" text="Get it Free!"]
Parameters:
| Parameter | Required | Default | Description |
|---|---|---|---|
id | No | Current page product | Product ID to display |
text | No | Default button text | Custom button text |
Examples:
[download_now_page]
On a product page, displays the download form for that product.
[download_now_page id="123"]
Displays download form for product ID 123.
[download_now_page id="456" text="Download All Files"]
Custom button text for multiple file products.
What It Displays:
For single file products:
- Download button or link (based on settings)
- PDF viewer button (if enabled)
- Login message (if required)
For multiple file products:
- Individual file links
- Download all button
- Checkboxes (if enabled)
- Based on your display method settings
Notes:
- This is a block-level element
- Respects all plugin settings (display method, button styling, etc.)
- If no ID specified, uses current page's product ID
- If product is not valid, nothing is displayed
[add_to_cart] - WooCommerce Shortcode
The standard WooCommerce [add_to_cart] shortcode works with free download products.
Usage:
[add_to_cart id="99"]
Behavior:
- If product is valid for free download, shows download button
- If product is not valid, shows standard "Add to Cart" button
- Automatically detects product eligibility
Example:
[add_to_cart id="123"]
Notes:
- This is WooCommerce's built-in shortcode
- The plugin automatically overrides it for free products
- No special parameters needed
- Falls back to standard behavior for paid products
Shortcode Use Cases
Product Pages and Theme Builders
When building product pages with a theme or page builder (e.g. Elementor, Divi), the automatic download button may not show because their product blocks often omit WooCommerce hooks. Add the shortcode without an ID so it uses the current product:
[download_now]
Or with custom text:
[download_now text="Download Now" align="center"]
Use this in a Shortcode widget or block within your product template; it will show the correct download button for each product.
Landing Pages
Create dedicated landing pages for free downloads:
<h1>Get Your Free eBook</h1>
<p>Download our comprehensive guide to WordPress development.</p>
[download_now_page id="123"]
<h2>What You'll Learn</h2>
<ul>
<li>WordPress basics</li>
<li>Theme development</li>
<li>Plugin creation</li>
</ul>
Sidebar Widgets
Add download buttons to sidebars using a Text widget:
<h3>Free Resources</h3>
[download_now id="123" text="Download Guide"]
[download_now id="456" text="Download Template"]
Blog Posts
Embed downloads in blog content:
In this tutorial, we'll show you how to create a contact form.
You can download the starter template below:
[download_now id="789" text="Download Starter Template" align="center"]
Now let's get started...
Custom Product Pages
Build custom product layouts:
<div class="custom-product-layout">
<div class="product-image">
[product_image id="123"]
</div>
<div class="product-download">
<h2>Free Download</h2>
[download_now_page id="123"]
</div>
</div>
Email Campaigns
Include download links in email templates (if your email system supports shortcodes):
Thanks for subscribing! Here's your free gift:
[download_now id="123" text="Claim Your Free eBook"]
Shortcode Styling
Shortcodes inherit the plugin's button and link styling from your settings.
Global Styling
To style all shortcode buttons:
- Go to WP Enhanced > Free Download Woo, then click General in the sidebar
- Set Button classes and Button CSS
- These styles apply to all download buttons, including shortcodes
Custom Styling Per Shortcode
To style individual shortcodes, wrap them in a div with a custom class:
<div class="my-custom-download">
[download_now id="123"]
</div>
Then add CSS:
.my-custom-download .somdn-download-button {
background-color: #ff6600;
color: white;
padding: 15px 30px;
border-radius: 8px;
}
Alignment Styling
The align parameter adds CSS classes:
align="left"→.somdn-align-leftalign="center"→.somdn-align-centeralign="right"→.somdn-align-right
You can style these classes in your theme:
.somdn-align-center {
text-align: center;
margin: 20px auto;
}
Troubleshooting Shortcodes
Shortcode Displays as Text
If you see [download_now id="123"] instead of a button:
- ✅ Verify shortcodes are enabled in your editor
- ✅ Check you're not in a code block
- ✅ Ensure the plugin is activated
- ✅ Try a different page/post
Nothing Displays
If the shortcode doesn't show anything:
- ✅ If using without
id: Ensure you're on a product page or inside a product template (e.g. theme builder single product layout). The shortcode needs a product context to work without an ID. - ✅ If using with
id: Verify the product ID is correct. - ✅ Check the product is free (price = 0)
- ✅ Ensure product is Downloadable and Virtual
- ✅ Verify at least one file is attached
- ✅ Check product is included in plugin settings
- ✅ Clear all caches
Wrong Product Displays
If the wrong product shows:
- ✅ Check the
idparameter is correct - ✅ Verify you're using the product ID, not post ID
- ✅ Test with a different product ID
Styling Doesn't Apply
If custom styling doesn't work:
- ✅ Check CSS specificity (use browser inspector)
- ✅ Verify CSS is loaded after plugin CSS
- ✅ Use
!importantif necessary (last resort) - ✅ Clear browser and server cache
Shortcode in Widget Doesn't Work
If shortcodes don't work in widgets:
- ✅ Ensure you're using a Text widget (not HTML widget)
- ✅ Check your theme supports shortcodes in widgets
- ✅ Try adding this to your theme's
functions.php:
add_filter('widget_text', 'do_shortcode');
Advanced Shortcode Usage
Conditional Display
Use PHP to conditionally display shortcodes:
<?php if (is_user_logged_in()) : ?>
[download_now id="123" text="Member Download"]
<?php else : ?>
<p>Please log in to download this file.</p>
<?php endif; ?>
Dynamic Product IDs
Use PHP to generate dynamic product IDs:
<?php
$product_id = get_post_meta(get_the_ID(), 'related_download', true);
echo do_shortcode('[download_now id="' . $product_id . '"]');
?>
Multiple Downloads
Display multiple downloads in a grid:
<div class="download-grid">
<div class="download-item">
<h3>eBook 1</h3>
[download_now id="123"]
</div>
<div class="download-item">
<h3>eBook 2</h3>
[download_now id="456"]
</div>
<div class="download-item">
<h3>eBook 3</h3>
[download_now id="789"]
</div>
</div>
Custom Wrapper
Wrap shortcodes in custom HTML:
<div class="featured-download">
<div class="download-badge">FREE</div>
<h2>Featured Download</h2>
<p>Get our most popular resource absolutely free!</p>
[download_now_page id="123"]
<p class="download-note">No signup required!</p>
</div>
Shortcode Filters (For Developers)
Developers can modify shortcode behavior using filters:
Modify Shortcode Arguments
add_filter('somdn_product_page_args', function($args) {
// Modify $args array
return $args;
});
Override Shortcode Output
add_filter('somdn_shortcode_output', function($output, $product_id) {
// Modify or replace $output
return $output;
}, 10, 2);
See Advanced: Filters for more details.
Best Practices
Product IDs
- On product pages or theme builder product templates: You can use
[download_now]without an ID; it will use the current product. - Elsewhere (sidebar, blog post, landing page): Specify the product ID, e.g.
[download_now id="123"]. - Verify IDs: Double-check product IDs before publishing when using
id. - Use constants: Define frequently-used IDs as PHP constants when embedding in non-product contexts.
Button Text
- Be specific: "Download eBook" is better than "Download"
- Match content: Use text that describes what's being downloaded
- Keep it short: 2-4 words is ideal
- Use action verbs: "Download", "Get", "Access"
Placement
- Use sparingly: Don't overuse shortcodes on a single page
- Logical placement: Place downloads where they make sense contextually
- Test on mobile: Ensure shortcodes work well on small screens
- Consider flow: Don't interrupt reading flow unnecessarily
Performance
- Limit per page: Don't use too many shortcodes on one page
- Cache-friendly: Shortcodes work with most caching plugins
- Test with cache: Always test with caching enabled
What's Next
- Display Options - Customize button appearance
- Single File Downloads - Single file behavior
- Multiple File Downloads - Multiple file behavior
- Template Customization - Advanced customization
- Advanced: Filters - Developer customization