문제

I am trying to append "DEV SRV:" to the page title (i.e. title tag) if the IP Address matches that of the dev server. I have tried this both in the functions.php file of my child theme and as a standalone plugin

add_filter('wp_title', 'dev_srv_title');
function dev_srv_title($title) {
        $host = $_SERVER['SERVER_ADDR'];
        if ($host =='0.0.0.0') {
                return 'DEV SRV: '.$title;
        }
    return $title;
}
도움이 되었습니까?

해결책

The issue was not persistent between multiple installations because there were multiple themes in use. The themes were creating the title tag in different ways.

Changed plugin based solution to inserting conditional banner content (and later a contextual feedback form) in wp_footer which is working regardless of theme (so far 😉)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 wordpress.stackexchange
scroll top