0

Suppose I am developing a minimal theme, the the post page single.php displays only the post title, the excerpt and the content.

So in general that would be

<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php the_content(); ?>

So I am expecting 3 queries...

Instead if I write a custom query where I am just fetching these 3 datas in an array at once...

<?php arr[] = get_row(select title, excerpt, content from wp_posts where post_id = 1); ?>
<?php echo arr[0] ?>
<?php echo arr[1] ?>
<?php echo arr[2] ?>

Which is faster or does it make a difference ?

Plz ignore syntax if wrong...

1
  • 1
    There are no native database queries in the WordPress functions the_title(), the_excerpt() and the_content(). You should profile your theme to better see where the queries come from. Many good tools out there.
    – birgire
    Jul 9 '14 at 9:29
3

Queries ofcourse. It's faster...

But in this case just please delete you wp site and start with something faster... here is my superfast framework for you...

<?php 
/*Your bunny wrote */

I did tests, 0.0000001 runtime vs WP usually 0.7-2.8

Sarcasm off

P/S/ This question have no sence since using direct queries and output of the variables isn't use advantages of the WP. Author obviosly CAN do that, but I am wandering why to use WP and not using all positive things of it.

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.