Add WordPress article sharing button manually (without plug-in) implementation steps

Time:2019-11-8

Add some sharing buttons to a good article to share it with some famous websites, which is good for the promotion of websites. There are many ways to add sharing buttons to the site. You can use the jithis tool to log in to jithis.com and set your preferred way to get the corresponding code. Here’s a manual way to add the WordPress article sharing button.

First look at the renderings

Method: create a new bookmark.php file, copy the following code to it, and upload it to the theme directory.

Copy code

The code is as follows:

<?php
$permalink = urlencode(get_permalink($post->ID));
$title = urlencode($post->post_title);
$title = str_replace(‘+’,’%20′,$title);
?>
<li>
<a href=”http://www.xianguo.com/service/submitdigg/?link=<?php echo $permalink; ?>&amp;
Title = < PHP echo $title;? ></a>
</li>
<li>
< a href = “http://www.double.com/recommended/? Url = < PHP echo $permalink;? > & title = < PHP echo $title;? > & sel = & v = 1” target = “? Blank” rel = “nofollow” > share to watercress</a>
</li>
<li>
“C =% 22% 22 + (window. Getselection? Window. Getselection(): document. Getselection? Document. Getselection(): document. Getselection? Document. Getselection(): document. Selection. Createrange(). Text); C = c.subst (0180); location =% 22http://zuosa.com/collect/collect.aspx? T =% 22 + encodeuricomponent (T) +% 22 & u =% 22 + encodeuricomponent% 22 + encodeuricomponent (T) +% 22% 22 & u =% 22 + encodeuricomponent =% 22 + encodeuricomponent (T) +% 22% 22 & u =% 22 + encodeuricomponent =% 22 + encodeuricomponent =% 22 + encodeuricomponent (T) +% 22 & u =% 22 + encodeuricomponent =% 22 + encodeuricomponent =% 22 + encodeuricomponent (T) +% 22 & u =% 22 + encodeuricomponent =% 22 + encodeuricomponent (T) +% 22 + (U); void% 200” > points What to enjoy</a>
</li>
<li>
< a href = “http://share.xiaonei.com/share/buttonshare.do? Link = < PHP the” permalink()? > & title = < PHP the “title();? >” target = “? Blank” rel = “nofollow” > share to renren.com</a>
</li>
<li>
< a href = “http://www.kaixin001.com/repast/share.php? Url = < PHP the” permalink()? > & title = < PHP the “title();? >” title = “share to happy net” target = “” blank “rel =” nofollow “> share to happy net</a>
</li>
<li>< a href = “http://v.t.sina.com.cn/share/share.php? Url = < PHP the” permalink()? > & title = < PHP the “title();? > target =” \\\\\\\\\\\\\\\\\\\\\\\\\\\</a></li>

Then set up CSS and add the following code to style.css of the theme

Copy code

The code is as follows:

/************************************************
* bookmark *
************************************************/
#share {
background:none repeat scroll 0 0 #FFF6EE;
-moz-border-radius:5px 5px 5px 5px;
-webkit-border-radius: 5px;
background:none repeat scroll 0 0 #FFF6EE;
border:1px solid #FFF6CC;
width:602px;
float:left;
}
#share li {
background:url(“images/share.gif”) no-repeat scroll 0 0 transparent;
float:left;
margin:6px 0 0 5px;
padding:4px 0 4px 20px;
list-style-type:none;
}
#share li#fanfou {
background-position:0 -44px;
}
#share li#facebook {
background-position:0 -22px;
}
#share li#friendfeed {
background-position:0 -66px;
}
#share li#douban {
background-position:0 -110px;
}
#share li#xiaonei {
background-position:0 -87px;
}
#share li#zuosa {
background-position:0 -130px;
}
#share li#myspace {
background-position:0 -153px;
}
#share li#kaixin001 {
background-position:0 -176px;
}
#share li#xianguo {
background-position:0 -199px;
}
#share li#sina {
background-position:0 -220px;
}

Then download the share button icon and upload it to the images directory of wordpress theme.

Finally, add the following code to the article template page (generally single. PHP)

Copy code

The code is as follows:

<div>
<ul><?php include(TEMPLATEPATH.”/bookmark.php”);?></ul>
</div>

OK, it’s all finished. The test is correct under IE8, FF and GG. In case of dislocation, please try to modify the CSS picture control width. If you don’t like the above sharing site, you can modify the website and icon yourself.