Pretty Links provides shortcodes you can use anywhere WordPress accepts shortcodes — posts, pages, widgets, page builders, and theme templates that support do_shortcode(). Shortcodes are a flexible way to insert dynamic link references into your content.
Inserting a Specific Link
Use the [prettylink] shortcode to insert any pretty link by its ID:
[prettylink id="42"]
This outputs a link to the pretty URL of the link with ID 42. The visible link text defaults to the link’s title.
You can find the ID of any link from the Pretty Links list — it’s shown next to or beneath the link’s title.
Customizing the Link Text
Override the visible text with the text attribute:
[prettylink id="42" text="Click here for our affiliate offer"]
This renders as a standard anchor tag with the text you provide pointing at the pretty URL.
Other supported attributes: slug (use instead of id to look up by slug), class (extra CSS classes), and target (e.g. target="_blank").
What Gets Honored
The [prettylink] output respects the link’s settings:
- Nofollow and Sponsored flags add the appropriate
relattributes; - Open in new window adds
target="_blank"(with saferel="noopener"); - The pretty URL is rendered, not the target URL — meaning click tracking, redirect type, and advanced features all apply when a visitor clicks.
Linking to the Current Post’s Auto-Created Pretty Link
If you’ve enabled auto-create links for a post type, every post in that type gets its own pretty link automatically. To embed that pretty link into the post’s own content (or a template), use:
[post-pretty-link]
By default this outputs the raw pretty URL string (not a clickable anchor). It’s commonly used in:
- Email-this-post buttons (“Share this post: yoursite.com/abc123”);
- Print-friendly templates that need a short URL to display;
- Theme footers that show a copyable short URL for each post.
Rendering as a Clickable Link
To wrap the URL in an <a> tag, pass link="anchor" (or any non-empty text attribute, which implies anchor mode):
[post-pretty-link link="anchor"]
[post-pretty-link text="Share this post"]
The first uses the link’s stored name as the anchor text; the second uses the text you provide.
If the current post doesn’t have an auto-created pretty link, the shortcode outputs nothing — so it’s safe to drop into a template that runs on every post.
Where Shortcodes Work
These shortcodes work everywhere WordPress evaluates shortcodes:
- Inside Classic Editor content (Visual or Text tab);
- Inside the Gutenberg Shortcode block;
- Inside Gutenberg paragraph blocks (auto-evaluated);
- Inside widgets (if your widget area runs
do_shortcode); - Inside theme files if the developer has wrapped output in
do_shortcode(); - Inside most page builders (Elementor, Beaver Builder, Divi, etc.).
If a shortcode appears as raw text on the page instead of being evaluated, the surrounding context isn’t running do_shortcode(). That’s a theme or page-builder configuration issue, not a Pretty Links bug.
What the Shortcodes Output
Both shortcodes output a standard <a> tag pointing at the pretty URL, not the target URL. That means:
- The visitor sees
yoursite.com/your-slugif they hover; - Clicks go through Pretty Links and are tracked;
- All redirect-type behavior (cloak, pretty bar, targeting, rotation, expiration) applies;
- Changing the link’s target later updates the destination without you editing the post content.
Tips
- Save link IDs once in a notes doc if you reuse the same handful of pretty links in many posts. It’s faster than looking each one up;
- Use the block-editor inserter when possible. The visual flow is friendlier for one-off insertions; shortcodes shine for templated content (like a recurring “subscribe” link in your post footer);
- Test in preview after adding a shortcode. If you see the raw shortcode text on the front end, the context isn’t evaluating shortcodes;
- Use the right attribute for slugs.
idonly takes a numeric link ID. To look up by slug, use theslugattribute in the shortcode:
[prettylink slug="my-slug"]