Tweet Button
-
Hi, I am putting a Tweet Button in my page.php file after the the loop.
This is my code:
<a href="https://twitter.com/share"> <?php echo the_slug(); ?>" data-text="Check Out <?php echo get_the_title(); ?>" data-via="twitter" data-related="twitter">Tweet </a> <script> !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs'); </script>
The
<?php echo the_slug(); ?>
is where the error is.This code is also in my functions file to get the slug:
function the_slug() { $post_data = get_post($post->ID, ARRAY_A); $slug = $post_data['post_name']; return $slug; }
When the Tweet Button has been clicked, it correctly displays the url in the twitter popup window but when submitted, Twitter shows an error.
See example page here
I have included a screenshot of the Twitter Error Page on Page 1.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Tweet Button’ is closed to new replies.