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 =='') {
                return 'DEV SRV: '.$title;
    return $title;
  • 1
    Can you debug if $_SERVER['SERVER_ADDR'] actually has the correct value (so your if gets triggered) or if the hook is not called at all? How is the title rendered in the theme? Are you using a SEO plugin? – kero Jan 26 at 15:45
  • @kero I was able to confirm that $host has the correct value by dropping this into my child theme's header.php file: <?php $host = $_SERVER['SERVER_ADDR']; echo '<!--DEBUG SERVER ADDRESS: '.$host.'-->'; ?> I am in fact using Yoast ... that's a great question and could be the issue ... – whakawaehere Jan 26 at 15:54
  • 1
    Quick search found these: wordpress.stackexchange.com/questions/305353/… & wordpress.stackexchange.com/questions/61472/… - does it help/answer your question? – kero Jan 26 at 16:03

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 😉)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.