Adding to data-text in tweet button



The code for the tweet button on my blog is:

<!-- Twitter tweet button Start --><b:if cond='data:blog.pageType != &quot;static_page&quot;'>
<div style='text-align:left;padding:5px 5px 5px 0;'>
<a class='twitter-share-button' data-count='horizontal' data-related='' data-via='johnsumer' expr:data-text='data:post.title' expr:data-url='data:post.url' href=''>Tweet</a>
<script src='' type='text/javascript'/>
<!-- Twitter tweet button End -->

I know that data-text sets the actual text to be tweeted and it currently gives the post title on the blog, e.g.: “I have a cat”. But I want it to appear it contatining the blog title, followed by ': ’ and then the post title, e.g. “My Blog: I have a cat”. How should I change the above code to do that?




Depends on your blogging software, but if you are using Wordpress you could have data-text=’’<?php bloginfo('name'); ?>: <?php wp_title("",true); ?>


Thank you for the reply, however I’m using blogspot.


what should I do in blogspot?


Same problem here. How can you do it in blogspot?


It’s possibile to have it in iframe code for wordpress?


yes it is, but I’m using blogspot :confused:




I’m using
expr:data-text='data:post.title + " by @EXDE601E"‘
on my blog, so I guess the solution for you would be:
expr:data-text=’"My blog: " + data:post.title’
Wrap everything in single quotes, wrap normal text in escaped quotes and link it together with +.



Thanks a lot, works exactly the way I want!




BTW, because of the newly introduced domain redirect based on the country where the viewer accesses the blog you should use expr:data-url=‘data:post.canonicalUrl’ instead of expr:data-url=‘data:post.url’.


Roger that.


hi i ma using tweet button into my website i try both iframe & javascript cannot add dynamically url …?

closed #14