I have made a new query after I've asked a question about my query_posts code... you guys didn't find that great, so I decided to change that.
I made this:
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$rand = new WP_Query("showposts=10&orderby=rand&paged=$page");
while($rand->have_posts()) : $rand->the_post();
My question is: how can I improve this?
Isn't it better to use an array? So the same code, with an array or not?
So like this:
$rand = new WP_Query( array(
'showposts' => '10',
'orderby' => rand
) );
Would this make my performance better?
And I read something about adding:
'update_post_meta_cache' => false
To improve the performance if terms are not going to be used. My question: what are terms anyway? Are they trying to say tags and / or categories with this?
Edit:
function random_posts( $query ) {
if ( $query->is_home() && !$query->is_paged() && $query->is_main_query() ) {
$query->set( 'orderby', 'rand' );
}
}
What if I would use this? Do I have to change my WP_Query or do I have to remove it? I don't get what pre_get_posts
does actually.
JS
and let the browser/user's device take the hit (1 person with single device vs 1000 or 10 000 people with one server - that's a big difference). Obviously there are limitations like with everything.JS
is super fast but it's limitations are set by user's device.