Tuesday, 15 June 2010

php - Wordpress Multiple Queries or a big array? -



php - Wordpress Multiple Queries or a big array? -

the site i'm working on has many queries , lot of same daily content. people's thought on creating big array upfront , slicing there after?

i'd think it's quick allow php more of work , give mysql bit of break.

thoughts?

$the_loop=new wp_query(array('posts_per_page'=>50, 'order-by'=>'post_date', 'order'=>'desc')); if(have_posts()) : while ($the_loop->have_posts()) : $the_loop->the_post(); foreach(get_the_tags() $tag){ $tags[]=$tag->name; } // categories foreach(get_the_category() $cat_item){ $category_array[]=$cat_item->cat_id; $category_name[]=$cat_item->name; } $the_post[]=array( //'the_id' => $post->id(), 'the_title' => get_the_title(), 'the_link' => get_permalink(), 'the_excerpt' => get_the_excerpt(), 'the_thumb' => wp_get_attachment_image_src(get_post_thumbnail_id($post->id),array(236,190)), 'the_image' => catch_that_image(), 'the_author' => get_the_author(), 'tags' => $tags, 'categories' => $category_array, 'featured' => in_category(231) ); endwhile; endif; wp_reset_query();

php wordpress

No comments:

Post a Comment