Button link: shortcode

Hi,

is it possible to add a shortcode in the link field of the button widget?
In Elementor I can do that, but in Bricks I do not see this possibility.
I would like to do that, because I would like to change the context for the button link:

Many thanks!

1 Like

I wonder if the Advanced dynamic data will work (you can try):
{echo:do_shortcode( ‘[my_shortcode]’ )}

Thanks for the suggestion, but unfortunately it does not work.
It just adds the shortcode as a string to the URL.

Sorry for the late reply. I believe in the link section for the bricks button is all about link generation unlike the elementor counterpart which converts into processing mode for shortcodes.

So, you may:

  1. use url parameters to trigger your shortcode upon button click
  2. use wpajax to execute shortcode upon button click to avoid page refresh

I tried with this script, but it did not work, unfortunately:

<script>
document.addEventListener('DOMContentLoaded', function () {
    // Get the button and the original URL
    var button = document.getElementById('brxe-svfrkk'); // Button ID
    var originalURL = 'https://www.example.com/'; // Original URL

    // Execute the shortcode and add the value to the URL when the button is clicked
    button.addEventListener('click', function () {
        var shortcodeValue = '[jet_engine_data dynamic_field_post_object="post_id" dynamic_field_filter=true filter_callbacks={filter_callback=get_permalink}]#[jet_engine_data dynamic_field_post_object="post_type" object_context="stack_previous"]';// This is the shortcode
        var parameter = 'dynamicParameter=' + encodeURIComponent(do_shortcode(shortcodeValue));
        var newURL = originalURL + '?' + parameter;
        window.location.href = newURL;
    });
});
</script>