Shortcode & PHP Methods
When you want to monetize one specific link instead of letting the Blog JavaScript convert everything, WP Safelink gives you a shortcode and a matching PHP method. Both turn a single target URL into a safelink on demand — perfect for hand-picking which download buttons inside a WordPress post route through your monetized countdown page.
The [wpsafelink] shortcode
The shortcode takes a target URL and returns a safelink URL. Wrap it inside an anchor tag’s href so the visible link text stays exactly how you want it:
<a href="[wpsafelink=https://www.example.com/file.zip]">Download Here</a>You can use it anywhere WordPress runs shortcodes — the post editor, widgets that support shortcodes, or page builders. When the page renders, WordPress replaces the shortcode with a fully formed safelink, so the visitor goes through your countdown page on click.
The PHP method
If you are editing a theme template, a page-template file, or a custom block where shortcodes are not parsed automatically, call do_shortcode() in PHP to produce the same safelink:
<?php echo do_shortcode('[wpsafelink=https://www.example.com/file.zip]'); ?>Drop this inside a download button in your template and it outputs the safelink URL just like the shortcode does in the editor.
When to use which
| Method | Where you use it | Returns |
|---|---|---|
[wpsafelink=URL] shortcode | Post/page editor, widgets, page builders | A safelink URL, ready to drop into an href |
do_shortcode('[wpsafelink=URL]') | Theme files, page templates, custom PHP | The same safelink URL, printed by your template |
Shortcode & PHP vs. the Blog JavaScript
These manual methods and the automatic Blog JavaScript all produce the same encrypted safelink — they just differ in how much you do by hand:
- Shortcode / PHP: precise, one link at a time. Best when only some links should be monetized.
- Blog JavaScript: automatic and site-wide. Best when most of your download links should be converted — see Include / Exclude Rules to control which ones.
💡 Note: The shortcode and PHP method work on the WordPress site where WP Safelink is installed. To monetize links on a separate WordPress blog automatically, pair it with the PRO Auto Convert Link extension, which converts links server-side and requires a valid WP Safelink PRO license.
Was this article helpful?