Breakdance4fun Logo

Hoster Plugin: Download Links Shortcode Solution

The plugin Hoster, by Dplugins, is a WordPress tool that allows developers to launch and manage plugin updates from a private location, bypassing WordPress.org restrictions and providing more control over plugin hosting and distribution.

While Hoster includes built-in Gutenberg download buttons, integration with page builders like Breakdance requires manual button implementation or custom PHP coding.

The solution below uses a shortcode approach to insert download links (and titles) throughout your site.

Step 1 - Implementing the Shortcode

Add this PHP code using your preferred snippet manager, such as WPCodeBox:

<?php

function hoster_download_shortcode($atts) {
$options = shortcode_atts(array(
'download_id' => 0,
'return' => 'url' // Default: returns URL (backward compatible)
), $atts);

$download_id = $options['download_id'];
$download_post = get_post($download_id);

if (!$download_post || $download_post->post_type !== 'downloads') {
return ''; // Invalid post or wrong post type
}

// Return different values based on 'return' parameter
switch ($options['return']) {
case 'title':
return esc_html($download_post->post_title);
case 'id':
return esc_attr($download_id);
case 'url':
default:
$selectedUrl = get_post_meta($download_id, 'download_url', true);
return $selectedUrl ? esc_url($selectedUrl) : '';
}
}
add_shortcode('hoster_download', 'hoster_download_shortcode');

Step 2 : Find the ID

Navigate to your Download list and locate the post ID for the download link you'd like to add. You'll find the post ID in the URL, displayed in this format:

/wp-admin/post.php?post=29&action=edit

Hoster download link

Step 3 - Add the shortcodes

Insert a Button element and set the text by choosing Shortcode from dynamic data options.
If you can't see the Shortcode option, set the Type to All and enable the option Disable Type Safety:

Hoster insert dynamic data

Then paste this shortcode, with your ID:

[hoster_download download_id="29" return="title"]
Hoster shortcode download title

Repeat the same process for the URL using this shortcode:

[hoster_download download_id="29"]
Hoster shortcode download url

That's all there is to it! This method works with other elements like Text Links, standard Text elements, and more.
It's also compatible with other page builders.