3

I'm using this code to generate the WhatsApp share button:

<a href="whatsapp://send?text=<?php echo get_the_title(); ?> <?php echo get_post_permalink(); ?>">Share via Whatsapp</a>

I want to add also ?utm_source=whatsapp in the URL.

How can I achieve this?

Andrew Lott
  • 5,914
  • 3
  • 25
  • 44
user873041
  • 41
  • 1
  • 2

3 Answers3

1

I guess you're using WordPress based on the get_post_permalink() so try replacing <?php echo get_post_permalink(); ?> with <?php echo get_post_permalink().'?utm_source=whatsapp'; ?> to append the attribute onto the link.

Andrew Lott
  • 5,914
  • 3
  • 25
  • 44
0
<a href="whatsapp://send?text=[TITLE] : [Link]?utm_source=site%26utm_medium=social_share%26utm_content=whatsapp" data-action="[Link]"></a>

This works for me

subindas pm
  • 101
  • 1
-2

You should url encode the = to %3D and it will work. And any & to %26.

Peps
  • 1
  • 1