Created
June 15, 2016 20:00
-
-
Save morganisok/2edd0ec21722eda4f25ad8bd51d5ba40 to your computer and use it in GitHub Desktop.
Add a "Tweet This" link to blockquotes in WordPress
This file contains hidden or 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
| /** | |
| * At the end of every blockquote, include a link to tweet the quote | |
| * | |
| * @param $content | |
| * | |
| * @return mixed | |
| */ | |
| function myprefix_add_twitter_link_to_blockquote( $content ) { | |
| $content = preg_replace( '#(<blockquote><p>)(.*)(</p></blockquote>)#m', '$1 $2 <a href="http://twitter.com/intent/tweet?status=$2 via @twitterusername ' . get_the_permalink() . '" class="genericon genericon-twitter" target="_blank">Tweet This</a> $3', $content ); | |
| return $content; | |
| } | |
| add_filter( 'the_content', 'myprefix_add_twitter_link_to_blockquote' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment