The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

REQUEST_URI versus is_home (2 posts)

  1. ElasticDog
    Posted 11 years ago #

    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?

  2. Joshua Sigar
    Posted 11 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic