WordPress links only on the first page to show the method (no plug-ins)

Source: Internet
Author: User
Keywords WordPress

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

There are a lot of WordPress link module on the Web page only displayed in the article, the practice is to use widget logic plug-ins, you can control any small module in a page is displayed. We all know that WordPress plug-ins more, the Web server is a certain pressure, I am a code-like, can use code to solve the problem, do not use Plug-ins, plug-ins are more like a full of things on my body, so I am not comfortable, today to introduce a way to modify the code, nonsense less said, on the code:

First step: First find wp-includes/widgets.php this file open

Step two: Search for foreach ((array) $sidebars _widgets[$index] as $id) {This Code

Step three: Write the following code behind the second step of the code

if ($wp _registered_widgets[$id] [' name ']== ' link ' &&!strpos ($_server[' php_self '], "wp-admin")) {

if (!is_home ()) re-enters; if (is_paged ()) re-enters;

The above code to achieve the function is, Friendship link this module, will only be shown in the WordPress home page, other pages do not show, on why to do so, please refer to the following article:

Http://www.admin5.com/article/20110629/355998.shtml

Code Description:

$WP _registered_widgets[$id] [' name ']== ' link]

Module title to be masked (depending on the title name of the module)

!strpos ($_server[' php_self '), "Wp-admin")

When the calling module is in the background, remove the mask

if (!is_home ()) re-enters;

In the non-homepage, the shielding module shows

if (is_paged ()) re-enters;

In the article page, the screen module shows

The above content is absolutely original, no plagiarism, by the way send my station: www.i5799.com

Related Article

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.