假设想让head中的robots相关meta代码如下:

<meta name='robots' content='noindex, nofollow' />
代码如下:
function ope_wp_robots_add_follow($robots)
{
    unset($robots['max-image-preview']);
    $robots['nofollow'] = true;
    $robots['noindex'] = true;
    return $robots;
}
add_filter('wp_robots', 'ope_wp_robots_add_follow');

更多用法可参考:

https://developer.wordpress.org/reference/hooks/wp_robots/