


How to add bookmarks to WordPress blog? (Attached with implementation code)
How to add bookmarks to WordPress blog? The following article will explain to you how to add favorite bookmarks in WordPress blogs, and attach the implementation code. I hope it will be helpful to you!
In the past two days, I have been tinkering with adding a "Social Bookmark" to the blog, which is a button under the article for readers to collect and share articles. There are many WordPress plug-ins available on the Internet to implement the bookmark function, but most plug-ins only provide a piece of JS code and nothing else, and the customization of the code is extremely poor.
The good news is that some websites provide code to implement the bookmark function, which is very good. So I did some testing, but the results were not very satisfactory. Some codes had failed, and too many small pictures were called, which increased the number of http connections and had a certain impact on the loading speed of the website. It is better to ask for help than to ask for help yourself. I downloaded the latest code from major bookmark websites. After a little piece together, I used CSS Sprites technology to combine these small pictures into one. The speed has obviously increased. In addition, the code has been optimized and passed W3C verification.
The picture below is the effect of a successfully created bookmark. Perhaps what you see below this article can give you a deeper experience:
Good things cannot be exclusive. Let’s share the process of making this bookmark collection button. Very simple.
1. Open single.php in your WordPress theme folder
2. Find and add the following code below (it’s a bookmark) Display position, or put it where you think is appropriate):
<div id="soucang"> <strong> <span style="color:#9932CC">收藏</span><span style="color:#57c200"> & </span> <span style="color:#9932CC">分享</span> </strong> <ul> <li id="kaixin"> <a href="http://www.kaixin001.com/repaste/share.php?rtitle=<?php echo urlencode($post->post_title);?>&rurl=<?php echo urlencode(get_permalink($post->ID));?>&rcontent=<?php $desc = strip_tags($post->post_excerpt); echo urlencode($desc); ?>" title="转贴到开心网" rel="nofollow"><span></span></a> </li> <li id="jiudian"> <a title="推荐到九点" href="http://www.douban.com/recommend/?url=<?php echo urlencode(get_permalink($post->ID));?>&title=<?php echo urlencode($post->post_title);?>" rel="nofollow"><span></span></a> </li> <li id="douban"> <a title="推荐到豆瓣" href="http://www.douban.com/recommend/?url=<?php echo urlencode(get_permalink($post->ID));?>&title=<?php echo urlencode($post->post_title);?>" rel="nofollow"><span></span></a> </li> <li id="yahoo"> <a title="雅虎收藏" href="http://myweb.cn.yahoo.com/popadd.html?url=<?php echo urlencode(get_permalink($post->ID));?>&title=<?php echo urlencode($post->post_title);?>" rel="nofollow"><span></span></a> </li> <li id="google"> <a href="http://www.google.com/bookmarks/mark?op=edit&bkmk=<?php echo urlencode(get_permalink($post->ID));?>&title=<?php echo urlencode($post->post_title);?>" title="Google书签" rel="nofollow"><span></span></a> </li> <li id="baidu"> <a href="http://cang.baidu.com/do/add?it=<?php echo urlencode($post->post_title);?>&iu=<?php echo urlencode(get_permalink($post->ID));?>" title="百度搜藏" rel="nofollow"><span></span></a> </li> <li id="qq"> <a href="http://shuqian.qq.com/post?from=3&title=<?php echo urlencode($post->post_title);?>&uri=<?php echo urlencode(get_permalink($post->ID));?>" title="收藏到QQ书签" rel="nofollow"><span></span></a> </li> <li id="vivi"> <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(vivi=window.open('http://vivi.sina.com.cn/collect/icollect.php?pid=www.ludou.org&title='+escape(d.title)+'&url='+escape(d.location.href)+'&desc='+escape(t),'vivi','scrollbars=no,width=480,height=480,left=75,top=20,status=no,resizable=yes'));vivi.focus();" title="保存到爱问ViVi收藏夹"><span></span></a> </li> <li id="bolaa"> <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(blog=window.open('http://www5.bolaa.com/CommendBlog/SmallLogin.aspx?title='+escape(d.title)+'&newspath='+escape(d.location.href)+'&subtitle='+escape(t),'bolaa','width=400px,height=400px'));blog.focus();" title="推荐到博拉"><span></span></a> </li> <li id="poco"> <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://my.poco.cn/fav/storeIt.php?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t)+'&img=http://www.h-strong.com/blog/logo.gif','keyit','scrollbars=no,width=475,height=575,status=no,resizable=yes'));keyit.focus();" title="收藏到POCO网摘" rel="nofollow"><span></span></a> </li> <li id="hexun"> <a href="javascript:t=document.title;u=location.href;e=document.selection?(document.selection.type!='None'?document.selection.createRange().text:''):(document.getSelection?document.getSelection():'');void(open('http://bookmark.hexun.com/post.aspx?title='+escape(t)+'&url='+escape(u)+'&excerpt='+escape(e),'HexunBookmark','scrollbars=no,width=600,height=450,left=80,top=80,status=no,resizable=yes'));" title="转帖到和讯网摘" rel="nofollow"><span></span></a> </li> <li id="delicious"> <a href="http://www.delicious.com/post?url=<?php echo urlencode(get_permalink($post->ID));?>&title=<?php echo urlencode($post->post_title);?>" title="deliciou" rel="nofollow"><span></span></a> </li> <li id="xianguo"> <script charset="utf8" type="text/javascript"> cT="0";nc="#444";nBgc="";nBorder="#F5E5A9";tc="#649B00";tBgc="#FFF4D0";tBorder="#F5E5A9";tDigg="%E6%8E%A8%E8%8D%90";tDugg="%E5%B7%B2%E8%8D%90";defaultItemUrl="WEB_URL";defaultFeedUrl ="http://feed.feedsky.com/ludou"; </script> <script type="text/javascript" charset="utf8" src="http://re.xianguo.com/api/diggthis.js"></script> </li> </ul> </div>
3. Please change the www.ludou.org URL in the above code to yours, and then add the following code to your WordPress theme CSS file :
#soucang { margin:15px auto; } #soucang ul { display:inline; position:absolute; } #soucang li { list-style:none; float:left; margin-right:10px; display:block; } #soucang li a span { /*请将下面的 http://example/m.gif 改成你自己的图片链接*/ background:url(http://example/m.gif) no-repeat; display:block; height:16px; width:16px; } #soucang li#baidu a span { background-position: 0 0; } #soucang li#bolaa a span { background-position: 0 -17px; } #soucang li#delicious a span { background-position: 0 -34px; } #soucang li#douban a span { background-position: 0 -85px; } #soucang li#google a span { background-position: 0 -102px; } #soucang li#hexun a span { background-position: 0 -119px; } #soucang li#jiudian a span { background-position: 0 -136px; } #soucang li#kaixin a span { background-position: 0 -153px; } #soucang li#poco a span { background-position: 0 -187px; } #soucang li#qq a span { background-position: 0 -204px; } #soucang li#vivi a span { background-position: 0 -221px; } #soucang li#yahoo a span { background-position: 0 -238px; } #soucang li#xianguo {margin-left:10px; padding-bottom:5px;}
The above code uses CSS Sprites technology, in which the background image of #soucang li a span
can be customized. Just put it in your website directory and change http:/ Just change /example/m.gif to your own image address. In addition, if the above CSS layout is not suitable for your blog, you can change it yourself.
Okay, this is the end of the story. Looking at these various bookmark buttons, don’t you feel very different? In fact, these bookmarks also help to beautify the website. If you have anything, please leave a message here.
Due to the limited width of the web page, only 16 mainstream bookmark buttons are provided here. Others can be added according to your own needs. Other bookmark codes and logo downloads are provided below, which are not original to me. After understanding the code provided above, it is not difficult to add it yourself.
Recommended study: "WordPress Tutorial"
The above is the detailed content of How to add bookmarks to WordPress blog? (Attached with implementation code). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Enable comments in WordPress website: 1. Log in to the admin panel, go to "Settings" - "Discussions", and check "Allow comments"; 2. Select a location to display comments; 3. Customize comments; 4. Manage comments, approve, reject or delete; 5. Use <?php comments_template(); ?> tags to display comments; 6. Enable nested comments; 7. Adjust comment shape; 8. Use plugins and verification codes to prevent spam comments; 9. Encourage users to use Gravatar avatar; 10. Create comments to refer to

Reasons why WordPress websites cannot be found in search engines: 1. Indexing issues; 2. Content issues; 3. Website technical issues; 4. Link issues; 5. Other issues such as geographical restrictions, website name and social media presence.

How to turn off a comment in WordPress? Specific article or page: Uncheck Allow comments under Discussion in the editor. Whole website: Uncheck "Allow comments" in "Settings" -> "Discussion". Using plug-ins: Install plug-ins such as Disable Comments to disable comments. Edit the topic file: Remove the comment form by editing the comments.php file. Custom code: Use the add_filter() function to disable comments.

WordPress Error Resolution Guide: 500 Internal Server Error: Disable the plug-in or check the server error log. 404 Page not found: Check permalink and make sure the page link is correct. White Screen of Death: Increase the server PHP memory limit. Database connection error: Check the database server status and WordPress configuration. Other tips: enable debug mode, check error logs, and seek support. Prevent errors: regularly update WordPress, install only necessary plugins, regularly back up your website, and optimize website performance.

Be cautious when building a WordPress website. The guide to breaking through pits helps you avoid risks: choose paid themes and avoid the quality and safety risks of free themes. "Less is more" when installing plugins to avoid website speed and compatibility issues. Regularly optimize the database to ensure the smooth operation of the website. Pay attention to security measures and regularly update and install security plug-ins. Modify the code carefully to avoid website crashes and do it in a test environment if necessary. Pay attention to performance optimization, improve website speed, and improve user experience.

To log in to a WordPress website account: Visit the login page: Enter the website URL plus "/wp-login.php". Enter your username and password. Click "Login". Verification Two-step Verification (optional). After successfully logging in, you will see the website dashboard.

How to copy WordPress code? Copy from the admin interface: Log in to the WordPress website, navigate to the destination, select the code and press Ctrl C (Windows)/Command C (Mac) to copy the code. Copy from a file: Connect to the server using SSH or FTP, navigate to the theme or plug-in file, select the code and press Ctrl C (Windows)/Command C (Mac) to copy the code.

You can install the FTP plug-in through WordPress, configure the FTP connection, and then upload the source code using the file manager. The steps include: installing the FTP plug-in, configuring the connection, browsing the upload location, uploading files, and checking that the upload is successful.
