Support » Fixing WordPress » REQUEST_URI versus is_home

  • I recently upgraded from 1.2.1 to, and am trying to redesign my site using the theme engine. Anyway, I want to cut down on as many queries and php calls as possible for speed purposes, and wondered if it would be faster to do something like:

    <?php if ($_SERVER["REQUEST_URI"] == '/') { echo " | your tagline here"; } ?>

    versus using the default template tag is_home to get the same results?

Viewing 1 replies (of 1 total)
  • global $wp_query->is_home is set automatically when a page is loaded; if you use it, it won’t add an extra (sql) query.

    Regarding to the speed, is_home() is a function while your code is inline code. Inline code is variably faster than a function call. But then your code is calling a server’s variable while is_home is already in memory. That may affect the speed ratio between them. And after all, everything I say is wrong until proven otherwise.

Viewing 1 replies (of 1 total)
  • The topic ‘REQUEST_URI versus is_home’ is closed to new replies.