I'm trying to add a custom "Tweet this" button to my WordPress posts. I'm sticking to the official Twitter guidelines.
Here is what I'm actually trying to pull of; I don't want the button, I want a custom look - for me it's only text. This is the code I use:
<a href="https://twitter.com/share?url=<?php echo urlencode(get_permalink($post->ID)); ?> &text=<?php the_title(); ?> &via=username&count=horizontal" class="custom-tweet-button">Tweet</a>
Output:
This is the post title via @username
So the problem is that the permalink (<?php the_permalink(); ?>
)doesn't get displayed.
I tried:
https://twitter.com/share?url=<?php echo urlencode(get_permalink($post->ID)); ?>
https://twitter.com/share?url=<?php the_permalink(); ?>
PS: I also tried the standard twitter button, not the custom one, but the permalink doesn't get displayed either.
Does anyone one if something is wrong with my code or if this is a problem since I'm using a local WordPress for development?