Created
July 2, 2011 04:47
-
-
Save epicdaze/1059744 to your computer and use it in GitHub Desktop.
#wordpress - tweet button with hashtags #twitter #tags #hashtags #whitespace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- /* Twitter button: post title and post tags. Prepend tags with hash symbol and remove whitespace within tags. */ --> | |
<a href="http://twitter.com/share" | |
class="twitter-share-button" | |
data-url="<?php bloginfo('url'); ?>/<?php the_ID(); ?>" | |
data-text="<?php the_title(); | |
// remove whitespace inside tags and prepend with # | |
$tags = get_the_tags(); | |
$tags_hashed = array(); | |
foreach((array)$tags as $tag) | |
$tags_hashed[] = str_replace(' ', '', $tag->name); | |
echo ' #'.implode(' #', $tags_hashed); ?>" | |
data-count="horizontal" data-via="twittername" data-lang="en">Tweet</a> | |
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> | |
<!-- /* Tweet will look like this: */ --> | |
Post title #tag #anothertag http://domain.com/42 via @twittername |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment