Title: Twitter Tweet coded into theme
Last modified: August 20, 2016

---

# Twitter Tweet coded into theme

 *  Resolved [baszer](https://wordpress.org/support/users/baszer/)
 * (@baszer)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/twitter-tweet-coded-into-theme/)
 * Hello,
 * on the [twitter developers page](https://dev.twitter.com/docs/tweet-button) you
   can find the following tweet button
 *     ```
       <script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
       <div>
          <a href="https://twitter.com/share" class="twitter-share-button"
             data-url="https://dev.twitter.com/pages/tweet_button"
             data-via="your_screen_name"
             data-text="Checking out this page about Tweet Buttons"
             data-related="anywhere:The Javascript API"
             data-count="vertical">Tweet</a>
       </div>
       ```
   
 * Now I want to hardcode this into my theme. I thought it should work with the 
   following code:
 *     ```
       <script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
       <div>
          <a href="https://twitter.com/share" class="twitter-share-button"
             data-url="<?php the_permalink(); ?>"
             data-text="<?php the_title(); ?>"
             data-count="vertical">Tweet</a>
       </div>
       ```
   
 * Now the problem comes. The title shows up fine, but there is no URL what so ever.
   What do I do wrong?
 * (the website is on a local server)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Jeremy Herve](https://wordpress.org/support/users/hd-j/)
 * (@hd-j)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/twitter-tweet-coded-into-theme/#post-2399372)
 * I have just tested your code locally, it works fine for me.
 * Where do you pleace that snippet of code in your theme?
 *  Thread Starter [baszer](https://wordpress.org/support/users/baszer/)
 * (@baszer)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/twitter-tweet-coded-into-theme/#post-2399385)
 * [@jeremy](https://wordpress.org/support/users/jeremy/)
 * > (the website is on a local server)
 * this was making the error
 * thanks for your answer.
 * For anyone who wants to code the tweet this into his theme (**with short permalink**):
 *     ```
       <script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
       <div>
          <a href="https://twitter.com/share" class="twitter-share-button"
             data-url="<?php echo get_bloginfo('url')."/?p=".$post->ID; ?>"
             data-text="<?php the_title(); ?>"
             data-count="vertical">Tweet</a>
       </div>
       ```
   
 *  [Jeremy Herve](https://wordpress.org/support/users/hd-j/)
 * (@hd-j)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/twitter-tweet-coded-into-theme/#post-2399392)
 * You can replace the_permalink by the_shortlink if you want, but I wouldn’t worry
   too much about that if I were you : Twitter automatically shortens your links
   with their t.co URL shortener.
 *  Thread Starter [baszer](https://wordpress.org/support/users/baszer/)
 * (@baszer)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/twitter-tweet-coded-into-theme/#post-2399394)
 * ow cool Jeremy, I also found another solution! 😉
 * Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Twitter Tweet coded into theme’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)

 * 4 replies
 * 2 participants
 * Last reply from: [baszer](https://wordpress.org/support/users/baszer/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/twitter-tweet-coded-into-theme/#post-2399394)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
