Reputation: 7025
Using the Twitter share button, I can't seem to pass links that has fragment identifiers. The links turn up with only the base path of the site (e.g. "http://mysite.com/"). I've been reading through the previous threads posted here about Twitter and sharing but I can't seem to get my head around if Twitter allows it, if there's a special parse method to be used etc.
I've tried both parsing a regular URL (http://mysite.com/#example) and a decoded version (http://mysite.com/%23example), none of which are working. Would appreciate any help or direction on this subject.
Upvotes: 1
Views: 555
Reputation:
Twitter automatically removes # from links, I had the same problem. To solve this I used the following code:
<a href="http://twitter.com/share?text=xxx&url=<?php echo esc_url ( get_permalink()); ?><?php echo "%23example"; ?>" target="_blank">
This part: <?php echo esc_url ( get_permalink()); ?>
is only relevant to WordPress but you can replace this with your URL.
Upvotes: 0
Reputation: 2923
Use a URL Shortening service.
A service that handles fragment identifiers, like TinyURL, can solve this for you. For example, "http://example.com/#example" becomes "http://tinyurl.com/85rtaym", and works as expected.
Upvotes: 1