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