WordPress links are only displayed on the homepage (no plug-ins)

Source: Internet
Author: User
Tags website server

There are a lot of articles on the WordPress link module displayed only on the homepage. The practice is to use the Widget Logic plug-in to control whether any small module is displayed on a page. As we all know, there are too many WordPress plug-ins and there is a certain amount of pressure on the website server. I am a code-driven. If I can solve problems with code, I don't need plug-ins, A lot of plug-ins are like something on me, which makes me uncomfortable. Today I want to introduce you to a way to modify the code:

Step 1: first find the wp-uplodes/widgets. php file to open

Step 2: Search for foreach (array) $ sidebars_widgets [$ index] as $ id) {This code

Step 3: Write the following code to the end of step 2.

If ($ wp_registered_widgets [$ id] ['name'] = "Link "&&! Strpos ($ _ SERVER ['php _ SELF '], "wp-admin ")){

If (! Is_home () continue; if (is_paged () continue;

The function implemented by the code above is that links to this module will only be displayed on the WordPress homepage, and other inner pages will not be displayed. For details about why you want to do so, refer to the following article:

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

Code Description:

$ Wp_registered_widgets [$ id] ['name'] = "Link"

Module title to be blocked (determined by the module title name)

! Strpos ($ _ SERVER ['php _ SELF '], "wp-admin ")

Unblocking when the calling module is in the background

If (! Is_home () continue;

When the homepage is not displayed, the module is blocked.

If (is_paged () continue;

When the document page number is displayed, the module is blocked.

The above content is absolutely original and never plagiarized. By the way, I will post my website: 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.