WordPress Search Page noindex Prohibits Search Engine Indexing Solution

Called by the theme through this function After saving the functions. PHP file and refreshing the webpage, the meta function of the entire robots will disappear......

WordPress Search Page noindex Prohibits Search Engine Indexing Solution

The search page header of WordPress has this meta:

<meta name=’robots’ content=’noindex, follow, max-image-preview:large’ />

How to remove this tag when it causes search engines to not index this page?

This code is not in header.php, nor is it in the theme file. It is in the WordPress internal file, but it is generated by the theme through<?php wp_head(); ?> This function is called and cannot be changed in the theme.

Although we cannot change this function, we can remove the built-in function that we do not need from the template file.

Removal noindex method:

Find the functions.php file in the theme file and then search for add_ There are many functions in the filter function, functions. PHP. Find any one and add the following code nearby:

    add_filter(‘wp_robots’, ‘fanly_basic_robots_remove_noindex’, 999);
    function fanly_basic_robots_remove_noindex( $robots ){
        return get_option(‘blog_public’) ? [] : $robots;
    }

After saving the functions.php file and refreshing the webpage, the meta functions of the entire robots will disappear. All WordPress pages on the entire website will no longer have this meta tag.

给TAReward
共{{data.count}}人
人已Reward
Losepoor Knowledge

How to make money by selling products on TikTok

2023-12-19 20:43:18

Losepoor Knowledge

Preface: A tutorial on website construction from 0 to 1

2024-1-8 1:20:35

0 comment A文章作者 M管理员
    No Comments Yet. Be the first to share what you think!
Profile
Cart
Coupons
Check-in
Message Message
Search