snipt

Ctrl+h for KB shortcuts

HTML

Add Twitters official Share button to WordPress Posts

<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
   <a href="http://twitter.com/share" class="twitter-share-button"
      data-url="<?php the_permalink(); ?>"
      data-via="wpbeginner"
      data-text="<?php the_title(); ?>"
      data-related="syedbalkhi:Founder of WPBeginner"
      data-count="vertical">Tweet</a>

/*explanation
data-url – This fetches the URL that you want to share (You do not need to change this).

data-via – This tells twitter who was the original tweeter by adding via @wpbeginner (Make sure you change it to your twitter account).
data-text – This fetches the title of your post (You do not need to change this).

data-related – This adds recommended users to follow. You are allowed up to two Twitter accounts for users to follow after they share content from your website. These accounts could include your own, or that of a contributor or a partner. The first account is the one that is shared in data-via property. (Make sure you change it to one of your other twitter accounts, or remove it). If you don’t, then you will be recommending @syedbalkhi (Founder of WPBeginner). The correct format to enter data in this variable is twitterusername:Description of the User

data-count – This tells twitter’s script which style of button you want to show. You have three option (vertical, horizontal, none).

data-lang – This variable tells twitter which language it should be in. Default value is ‘en’ for English, and we have left it at that.*/

/*
source:http://www.wpbeginner.com/wp-tutorials/how-to-add-twitters-official-tweet-button-in-wordpress/
*/
https://snipt.net/embed/c3b81829567d5625503b346422603ebf/
/raw/c3b81829567d5625503b346422603ebf/
c3b81829567d5625503b346422603ebf
html
HTML
23
2019-08-20T23:02:53
True
False
False
/api/public/snipt/26748/
add-twitters-official-share-button-to-wordpress-posts
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1"> 1</a> <a href="#L-2"> 2</a> <a href="#L-3"> 3</a> <a href="#L-4"> 4</a> <a href="#L-5"> 5</a> <a href="#L-6"> 6</a> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a> <a href="#L-12">12</a> <a href="#L-13">13</a> <a href="#L-14">14</a> <a href="#L-15">15</a> <a href="#L-16">16</a> <a href="#L-17">17</a> <a href="#L-18">18</a> <a href="#L-19">19</a> <a href="#L-20">20</a> <a href="#L-21">21</a> <a href="#L-22">22</a> <a href="#L-23">23</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;http://platform.twitter.com/widgets.js&quot;</span> <span class="na">type</span><span class="o">=</span><span class="s">&quot;text/javascript&quot;</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span> </span><span id="L-2"><a name="L-2"></a> <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;http://twitter.com/share&quot;</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;twitter-share-button&quot;</span> </span><span id="L-3"><a name="L-3"></a> <span class="na">data-url</span><span class="o">=</span><span class="s">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span> </span><span id="L-4"><a name="L-4"></a> <span class="na">data-via</span><span class="o">=</span><span class="s">&quot;wpbeginner&quot;</span> </span><span id="L-5"><a name="L-5"></a> <span class="na">data-text</span><span class="o">=</span><span class="s">&quot;&lt;?php the_title(); ?&gt;&quot;</span> </span><span id="L-6"><a name="L-6"></a> <span class="na">data-related</span><span class="o">=</span><span class="s">&quot;syedbalkhi:Founder of WPBeginner&quot;</span> </span><span id="L-7"><a name="L-7"></a> <span class="na">data-count</span><span class="o">=</span><span class="s">&quot;vertical&quot;</span><span class="p">&gt;</span>Tweet<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span> </span><span id="L-8"><a name="L-8"></a> </span><span id="L-9"><a name="L-9"></a>/*explanation </span><span id="L-10"><a name="L-10"></a>data-url – This fetches the URL that you want to share (You do not need to change this). </span><span id="L-11"><a name="L-11"></a> </span><span id="L-12"><a name="L-12"></a>data-via – This tells twitter who was the original tweeter by adding via @wpbeginner (Make sure you change it to your twitter account). </span><span id="L-13"><a name="L-13"></a>data-text – This fetches the title of your post (You do not need to change this). </span><span id="L-14"><a name="L-14"></a> </span><span id="L-15"><a name="L-15"></a>data-related – This adds recommended users to follow. You are allowed up to two Twitter accounts for users to follow after they share content from your website. These accounts could include your own, or that of a contributor or a partner. The first account is the one that is shared in data-via property. (Make sure you change it to one of your other twitter accounts, or remove it). If you don’t, then you will be recommending @syedbalkhi (Founder of WPBeginner). The correct format to enter data in this variable is twitterusername:Description of the User </span><span id="L-16"><a name="L-16"></a> </span><span id="L-17"><a name="L-17"></a>data-count – This tells twitter’s script which style of button you want to show. You have three option (vertical, horizontal, none). </span><span id="L-18"><a name="L-18"></a> </span><span id="L-19"><a name="L-19"></a>data-lang – This variable tells twitter which language it should be in. Default value is ‘en’ for English, and we have left it at that.*/ </span><span id="L-20"><a name="L-20"></a> </span><span id="L-21"><a name="L-21"></a>/* </span><span id="L-22"><a name="L-22"></a>source:http://www.wpbeginner.com/wp-tutorials/how-to-add-twitters-official-tweet-button-in-wordpress/ </span><span id="L-23"><a name="L-23"></a>*/ </span></pre></div> </td></tr></table>
share, social, twitter, wordrpess