Referral Widget Shortcodes
The plugin registers several shortcodes you can place anywhere WordPress accepts shortcodes — posts, pages, custom post types, widget areas, Gutenberg blocks (using the Shortcode block), or theme template files via do_shortcode().
All shortcodes render a container element on the page, then the AdvocateLoop widget JavaScript populates the container with the appropriate UI from your brand settings. The widget is server-rendered by the AdvocateLoop API, so colors, copy, and behavior reflect your dashboard configuration immediately when you change them — no need to clear caches or re-save WordPress pages.
[advocate_loop_widget]
The most common shortcode. Automatically shows the right widget for the visitor:
- If the visitor arrived via a referral link, the claim widget appears (so they can claim the discount)
- If the visitor wasn’t referred, the share widget appears (so they can become an advocate themselves)
[advocate_loop_widget]Attributes
| Attribute | Values | Default | Description |
|---|---|---|---|
type | auto, share, claim | auto | Forces a specific widget instead of letting the plugin choose. |
position | inline, modal, floating | inline | How the widget displays on the page. |
Examples
[advocate_loop_widget][advocate_loop_widget type="share"][advocate_loop_widget position="floating"][advocate_loop_share]
Always shows the share widget, regardless of whether the visitor was referred. Use this when you want to give every visitor the chance to become an advocate (for example, on your homepage or a dedicated “Refer a friend” page).
[advocate_loop_share]Attributes
| Attribute | Values | Default |
|---|---|---|
position | inline, modal, floating | inline |
Examples
[advocate_loop_share][advocate_loop_share position="modal"][advocate_loop_claim]
Always shows the claim widget. Useful on landing pages built specifically for referral campaigns, where the visitor is expected to have arrived via a referral link.
[advocate_loop_claim]Attributes
| Attribute | Values | Default |
|---|---|---|
position | inline, modal, floating | inline |
Examples
[advocate_loop_claim][advocate_loop_claim position="inline"][referral_share_buttons]
Renders just the social share buttons (Facebook, X/Twitter, WhatsApp, email, copy-link, etc.) without the full widget. Useful if you want to drop share buttons into a custom UI you’ve built yourself — for example, on an order-confirmation page that already shows the customer’s referral link in your own design.
[referral_share_buttons]This shortcode only renders meaningfully if the visitor already has a referral link assigned (i.e., they’ve signed up as an advocate). On pages where the visitor hasn’t signed up yet, the buttons won’t appear.
Position values explained
The position attribute controls how the widget displays on the page:
-
inline(default) — The widget renders in the exact spot the shortcode is placed, flowing with the rest of the page content. This is the most common choice and the most predictable for layout. -
modal— The widget appears in an overlay dialog when triggered. The shortcode placement still matters (it provides the trigger), but the widget itself opens centered over the page. -
floating— A persistent button stays in a corner of the screen; clicking it opens the widget. Useful for site-wide access to the referral program without needing to add the widget to every page.
The exact appearance of each position (colors, animation, button placement) is controlled in the AdvocateLoop dashboard under Configure → Widget.
Where to place shortcodes
A few common patterns:
| Goal | Suggested placement |
|---|---|
| Capture referrals on every page | Use a floating widget added to your theme’s footer.php via do_shortcode('[advocate_loop_widget position="floating"]') |
| Dedicated referral landing page | Create a “Refer a Friend” page and add [advocate_loop_share] inline |
| Show on product pages only | Add [advocate_loop_widget] to your product template, or use a plugin like Custom Content Shortcode to scope it |
| Show on post-purchase pages | The WooCommerce extension handles this automatically on the order-received page; for non-WooCommerce checkouts, place [advocate_loop_share] on your thank-you page |
Caching notes
The shortcode itself just outputs a small placeholder HTML element. The actual widget content is loaded by JavaScript from the AdvocateLoop API at runtime, so:
- Page caching plugins (WP Rocket, W3 Total Cache, etc.) can safely cache pages that contain AdvocateLoop shortcodes. The widget will still load correctly because the rendering happens client-side after the cached page is served.
- No need to exclude shortcodes from cache for the widget to work.
- The exception is the WooCommerce checkout page itself — that page should never be cached anyway because it’s session-specific.
Related
- Installation & Setup — Get the plugin connected
- Settings Reference — Configure how the widget looks and behaves
- Connecting Zapier, Make, and Custom Backends — Send events into AdvocateLoop from external systems