• Resolved baszer

    (@baszer)


    Hello,

    on the twitter developers page 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)
  • 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

    (@baszer)

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

    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

    (@baszer)

    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.