Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I plan to implement some specific content for specific categories only, about 15. I wonder will wordpress conditionals (15 if) slow down my website visibly? Sorry if this sounds silly.

share|improve this question
    
Can you edit your question to elaborate a little more? What type of content? Is it from your Wordpress site? Is it from another website? The more details, the better. –  Travis Pflanz Apr 22 '12 at 17:19

2 Answers 2

Conditional Tags are basically just short wrapper functions for parts of the global $wp_query;.

Example: is_author();

function is_author( $author = '' ) {
    global $wp_query;

    if ( ! isset( $wp_query ) ) {
        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
        return false;
    }

    return $wp_query->is_author( $author );
}

And this ↑ just retrieves a class var from the WP_Query object. That's it. So: No, they can't really add any noticeable overhead (unless you don't get millions of synchronous hits). Not more than interacting with any other object.

share|improve this answer

The answer is no but just to put your question into perspective I tried the following code. 1.5 million ifs.

$start = microtime();
$count = 0;
while(true) {
    $count++;
    if($count > 1500000) {
        break;
}
}
$stop = microtime();

$total = $stop-$start;
print "Total time:$total";

0.16 seconds

share|improve this answer
    
That's not really relevant, he may be calling an expensive function within the IF statement –  onetrickpony Apr 22 '12 at 20:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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