Shortcodes
Ask AI
Use the [copy] shortcode for precise control over copy buttons in your WordPress content. Perfect for coupon codes, deals, contact info, and inline copy buttons.
TL;DR Wrap any text in [copy]...[/copy] to add a one-click copy button—no coding required.
# What are Shortcodes?
Shortcodes are WordPress macros that let you add dynamic content using simple tags. The [copy] shortcode adds a copy button to any content you wrap it around.
Easy to Use
Wrap content with [copy]...[/copy]; no coding required
Customizable
Control text, style, and behavior
Works Everywhere
Posts, pages, widgets, builders
# 1 Basic Usage
Add a copy button anywhere by wrapping your text between [copy] and [/copy].
Basic Syntax
Example
In the editor
My Page
On the frontend
Preview
Browsernpm install clipboard text attribute to copy something different.
# 2 All Attributes
Customize the shortcode behavior with these attributes.
| Attribute | Default | Description |
|---|---|---|
| text | "" | Value copied to clipboard. If empty, inner content is copied. |
| display | inner content or text | Visible label. When inner content is present, it is used; otherwise text. |
| preset | inline | Style: inline, button, icon, cover |
| button-text | "Copy" | Button label (for preset="button" or cover) |
| success-text | "Copied!" | Message shown after copy (alias: copied-text) |
| content | "" | Legacy: when set, this is copied and text is the visible label |
| tag | span | Use a for link-style (theme styling); otherwise span |
| copy-as | text | Copy format: text or html |
| redirect | "" | URL to open after copying (new tab). Use this in new shortcodes. |
| link | "" | Same as redirect. Kept for backward compatibility. |
| class | "" | Custom CSS class(es) |
| id | "" | Custom ID attribute |
# 3 Examples
Copy these examples to get started quickly.
Coupon Code
PopularShow the code and copy it on click. For a button label, use preset="button" with button-text.
In the editor
Coupon Page
On the frontend
Preview
BrowserButton style: [copy preset="button" text="SAVE20" button-text="Copy Code"] → blue button “Copy Code” that copies SAVE20.
Code Snippet
Wrap the command or snippet; it is shown and copied.
In the editor
Docs
On the frontend
Preview
Browsernpm install @clipboard/react Email Address
Same as coupon: wrap the value so it is shown and copied.
In the editor
Contact
On the frontend
Preview
BrowserIcon Style (Minimal)
Only the copy icon is shown; text is the value copied.
In the editor
Promo
On the frontend
Preview
BrowserCopies PROMO50 when clicked.
Copy & Redirect
Use preset="button" so text is copied and button-text is the label; link opens after copy.
In the editor
Deal
On the frontend
Preview
BrowserCopies DEAL50, then opens the link in a new tab.
In WordPress, add the shortcode using the Shortcode block (Block Editor) or an HTML/shortcode widget in classic editor or page builders.
# 4 Styling
Customize the appearance of your copy buttons with CSS classes or inline styles.
Can I style the copy button? Yes. Use attributes like button-text, copied-text, and CSS classes. See the All Attributes table above for full options.
Using Custom Classes
Add custom CSS classes to style your copy buttons.
Then define .my-custom-btn in your theme's CSS.
Default CSS Classes
These classes are automatically added and can be targeted with CSS.
| Class | Applied To |
|---|---|
| .ctc-shortcode | Main wrapper (all presets) |
| .ctc-shortcode--inline | Inline preset |
| .ctc-shortcode--button | Button preset |
| .ctc-shortcode--icon | Icon preset |
| .ctc-shortcode__icon | Icon element |
| .ctc-shortcode--copied | Added briefly after successful copy |
# 5 Advanced Usage
Power user techniques for complex use cases.
Copy as HTML
Preserve HTML formatting when copying (useful for rich text).
Render as Button Element
Use preset="button" for a semantic button; text is copied, button-text is the label.
Combining Multiple Attributes
Use preset="button" with text (copy payload), button-text, success-text, link, and class.
Using in Page Builders
Shortcodes work in most page builders.
- Elementor: Use the Shortcode widget or HTML widget
- Beaver Builder: Use the HTML module
- Divi: Use the Code module or Text module
- Gutenberg: Use the Shortcode block
# 6 Troubleshooting
Common issues and how to fix them.
Shortcode shows as plain text
- Ensure the plugin is activated
- Check for typos in the shortcode name
- Make sure you're using square brackets
[] - Verify shortcodes are enabled for your content type
Copy button doesn't work
- Check for JavaScript errors in browser console (F12)
- Ensure no conflicting JavaScript from other plugins
- Verify the site uses HTTPS (required for clipboard API)
- Clear browser and plugin caches
Styling looks wrong
- Check for theme CSS conflicts
- Use browser DevTools to inspect applied styles
- Add more specific CSS selectors to override
- Use
!importantif necessary
Special characters not copying correctly
- Use HTML entities for special characters
- Use the
textattribute to specify exact copy text - Avoid smart quotes from word processors