{"id":198,"date":"2021-10-04T11:12:37","date_gmt":"2021-10-04T11:12:37","guid":{"rendered":"https:\/\/ethosspace.com\/programmers\/?p=198"},"modified":"2021-12-06T09:07:18","modified_gmt":"2021-12-06T09:07:18","slug":"how-to-add-social-share-icon-in-wordpress-without-plugin","status":"publish","type":"post","link":"https:\/\/ethosspace.com\/programmers\/how-to-add-social-share-icon-in-wordpress-without-plugin\/","title":{"rendered":"How to add social share icon in WordPress without plugin"},"content":{"rendered":"\n<p>Here is 10 line code that needs to add in the single.php file. This will avoid external calls, maintenance of plugins and improve speed.<\/p>\n\n\n\n<p>Step 1) Navigate to <strong>&#8220;Appearance&#8221;<\/strong> -&gt; <strong>Theme Editor<\/strong><\/p>\n\n\n\n<p>Step 2) Observe Theme Files section available on Right side of the page (in middle)<\/p>\n\n\n\n<p>Step 3) Search for <strong>single.php<\/strong> file (available in functions.php section)<\/p>\n\n\n\n<p>Step 4) Click on Single.php File .. .System will open it in write mode.<\/p>\n\n\n\n<p>Step 5) Add below code before or after content in a single.php file. ( Just above main or primary section or above to sidebar or footer section)<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>&lt;?php $url = urlencode(get_the_permalink()); $title = htmlspecialchars(urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, &#39;UTF-8&#39;)), ENT_COMPAT, &#39;UTF-8&#39;); ?&gt;\n \n&lt;div class=&#39;social-share&#39;&gt;\n&lt;a class=&#39;fb&#39; target=&quot;_blank&quot; href=&quot;http:\/\/www.facebook.com\/sharer.php?u=&lt;?php echo $url;?&gt;&quot;&gt;Facebook&lt;\/a&gt;\n&lt;a class=&#39;tw&#39; target=&quot;_blank&quot; href=&quot;https:\/\/twitter.com\/intent\/tweet?url=&lt;?php echo $url;?&gt;&text=&lt;?php echo $title; ?&gt;&quot;&gt;Twitter&lt;\/a&gt;\n&lt;a class=&#39;pi&#39; href=&quot;javascript:void((function()%7Bvar%20e=document.createElement(&#39;script&#39;);e.setAttribute(&#39;type&#39;,&#39;text\/javascript&#39;);e.setAttribute(&#39;charset&#39;,&#39;UTF-8&#39;);e.setAttribute(&#39;src&#39;,&#39;\/\/assets.pinterest.com\/js\/pinmarklet.js?r=&#39;+Math.random()*99999999);document.body.appendChild(e)%7D)());&quot;&gt;Pinterest&lt;\/a&gt;\n&lt;a class=&#39;go&#39; target=&quot;_blank&quot; href=&quot;https:\/\/plus.google.com\/share?url=&lt;?php echo $url;?&gt;&quot;&gt;Google+&lt;\/a&gt;\n&lt;a class=&#39;li&#39; target=&quot;_blank&quot; href=&quot;http:\/\/www.linkedin.com\/shareArticle?mini=true&url=&lt;?php echo $url;?&gt;&quot;&gt;Linkedin &lt;\/a&gt;\n&lt;a class=&#39;wh&#39; href=&quot;whatsapp:\/\/send?text=&lt;?php echo ($title .&quot; &quot;. $url);?&gt;&quot;&gt;WhatsApp&lt;\/a&gt;\n&lt;a class=&#39;ma&#39; target=&quot;_blank&quot; href=&quot;mailto:?subject=&lt;?php echo $title;?&gt;&body=%20&lt;?php echo $url;?&gt;&quot;&gt;EMAIL&lt;\/a&gt;\n&lt;\/div&gt;<\/code><\/pre><\/div>\n\n\n\n<p>Source : <a href=\"https:\/\/www.barattalo.it\/coding\/fastest-social-shares-without-plugins-in-wordpress\/\" rel=\"nofollow\" title=\"https:\/\/www.barattalo.it\/coding\/fastest-social-shares-without-plugins-in-wordpress\/\">barattalo<\/a><\/p>\n\n\n\n<p>Step 6) Add below CSS code to design social text as button. Below code can be added in external CSS plugin or Themes -&gt; Customize-&gt;Additional CSS Section.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.social-share {margin:20px 0;}\n.social-share a {\n    display:inline-block; width:auto; height:30px; \n    background-color:#efefef; text-decoration:none;\n    line-height:30px; padding:0 10px;\n    font-size:10px;color:#fff!important;\n    letter-spacing:0.4;text-transform:uppercase;\n}\n.social-share a.fb {background-color:#3a5795;}\n.social-share a.tw {background-color:#00ccff;}\n.social-share a.go {background-color:#ff6633;}\n.social-share a.pi {background-color:#ff0000;}\n.social-share a.li {background-color:#3366ff;}\n.social-share a.wh {background-color:#009900;display:none;}\n.social-share a.ma {background-color:#999999;}\n@media only screen and (max-width: 480px) {\n    .social-share a.wh {display:inline-block;}\n}<\/code><\/pre>\n\n\n\n<p>Whats app share icon is visible only on mobile phone. Can change settings by editing css.<\/p>\n\n\n\n<p>In place of text button we can also use fab class for example =&#8217;fab fa-facebook&#8217; to convert them in icon. and css for this is &#8220;.social-share a.fab.fa-facebook {background-color:#3a5795;}&#8221;<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is 10 line code that needs to add in the single.php file. This will avoid external calls, maintenance of plugins and improve speed. Step 1) Navigate to &#8220;Appearance&#8221; -&gt; Theme Editor Step 2) Observe Theme Files section available on Right side of the page (in middle) Step 3) Search for single.php file (available in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[13],"tags":[],"class_list":["post-198","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"aioseo_notices":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"sparkling-featured":false,"sparkling-featured-fullwidth":false,"tab-small":false},"uagb_author_info":{"display_name":"program45_-rt8nb","author_link":"https:\/\/ethosspace.com\/programmers\/author\/program45_-rt8nb\/"},"uagb_comment_info":0,"uagb_excerpt":"Here is 10 line code that needs to add in the single.php file. This will avoid external calls, maintenance of plugins and improve speed. Step 1) Navigate to &#8220;Appearance&#8221; -&gt; Theme Editor Step 2) Observe Theme Files section available on Right side of the page (in middle) Step 3) Search for single.php file (available in&hellip;","_links":{"self":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/comments?post=198"}],"version-history":[{"count":5,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/198\/revisions"}],"predecessor-version":[{"id":1067,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/198\/revisions\/1067"}],"wp:attachment":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/media?parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/categories?post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/tags?post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}