1
<li class='whatsapp whatsapp-mobile'>
    <a expr:href='"https://api.whatsapp.com/send?text=" + data:post + " | "' class='whatsapp'  rel='nofollow' target='_blank'/>
</li>

I tried this by using the above code snippet but it doesn't work.

Instead of data:post data tag, I also tried date:post.body data tag, but that didn't work as well.

Prayag Verma
  • 5,581
  • 3
  • 30
  • 56
Nickel
  • 41
  • 5

1 Answers1

0

To make this work, the snippet operator will need to coupled with jsonEscaped function. Applying this on the data:post.body data tag will get the full text of the post.

snippet(data:post.body,{ ellipsis: false, links: false, linebreaks: false }).jsonEscaped

The snippet operator is used without any length option to prevent any character limit being applied. Regarding the other options used, refer to How to increase character lengh in blogger snippet instead of using limited length, 'data:post.snippet'?

The complete code will look like -

<li class='whatsapp whatsapp-mobile'>
  <a expr:href='"https://api.whatsapp.com/send?text=" + snippet(data:post.body,{ ellipsis: false, links: false, linebreaks: false }).jsonEscaped + " | "' class='whatsapp' rel='nofollow' target='_blank'/>
</li>

The jsonEscaped function will cause linebreak character to be replaced by \n. Whatsapp doesn't treat \n as a new line and will get literally printed as is in the shared text.

Prayag Verma
  • 5,581
  • 3
  • 30
  • 56
  • Works Great... Is there anyway to remove that `\n` – Nickel Mar 08 '19 at 16:54
  • Try something like - `` `Share` – Prayag Verma Mar 11 '19 at 13:04
  • I tried ... But not useful... But I added `%0A` in post body at every line break with white text. – Nickel Mar 13 '19 at 05:22