Home Forums General Issues Dynamic whatsapp number with fixed url and appended text


Dynamic whatsapp number with fixed url and appended text

  • Hi! I’m trying for several months now to achieve a specific task.
    I want to have a field in which I can input the whatsapp number, but to have the “” and the append text “?text=exampletext” already fixed.

    Hope that makes sense. The reason I need this is that I use a frontend from for user to create posts and input their contact info.

    I tried the text field with prepend and append, but it’s not working.

    Any guidance will be greatly appreciated!

  • I found a way to do it!

    I made 3 shortcodes, one for the “https” part, one for the “whatsapp number” ACF field, and one for the final message.

    It works great.

  • I leave the exact code in case someone needs it

    // Prepend shortcode
      function https_wa_shortcode() {
        return '';
    add_shortcode('https_wa', 'https_wa_shortcode');
    // Append shortcode
      function hi_wa_shortcode() {
        return '?text=Hi! ';
    add_shortcode('hi_wa', 'hi_wa_shortcode');
    // Post title shortcode
    function post_title_shortcode(){
        return get_the_title();
    // Append shortcode
      function text_wa_shortcode() {
        return ', here is the last part of the text.';
    add_shortcode('text_wa', 'text_wa_shortcode');
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.