Search code examples
bloggerwhatsapp

How do share full body content


<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.


Solution

  • 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.