WordPress visitor greetings from XX friends

Source: Internet
Author: User


Yu Xiankang Youyou asked me last night how to implement this welcome word on my blog.

In fact, a major string of Google is code.

But to gather an article, send it out.

Add the above code to the topic's functions. php.

The code is as follows: Copy code

Function show_refer_in (){
$ Refer_info = $ _ SERVER ['http _ referer'];
$ Ban_list = array ($ _ SERVER ["HTTP_HOST"]);
For ($ ii = 0; $ ii <count ($ ban_list); $ ii ++ ){
If (strpos ($ refer_info, $ ban_list [$ ii]) {
Return;
}
}
If ($ refer_info ){
Preg_match ("/^ (http ://)? ([^/] +)/I ",
$ Refer_info, $ matches );
$ Host = $ matches [2];
Echo "<div id =" hellobaby "> Welcome to friends from". $ host! <Br/> we recommend that you <B> <a href = "http://www.111cn.net" target = "_ blank"> click here </a> </B> subscribe to my blog o (& cap; _ & cap;) o <div class = "closebox"> <a href = "javascript: void (0)" onclick = "inline ('display', 'none '); "title =" close "> × </a> </div> ";
}
}


Then, call the function in footer. php.

The code is as follows: Copy code
<? Php show_refer_in ();?>

Of course, it can also be added to the header, but it will not be worth the candle if the speed of opening is affected.

With the output, we must add css.

Here is the css code used by a blog.

CSS

The code is as follows: Copy code

# Hellobaby {background: #000000; border: 1px solid # B3B3B3; color: # FFFFFF; font-size: 14px; opacity: 0.7; filter: alpha (opacity = 70 ); padding: 10px; position: absolute; right: 0; top: 250px ;}

 
# Hellobaby {
Background: #000000;
Border: 1px solid # B3B3B3;
Color: # FFFFFF;
Font-size: 14px;
Opacity: 0.7;
Filter: alpha (opacity = 70 );
Padding: 10px;
Position: absolute;
Right: 0;
Top: 250px;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.