Wordpress多个查询还是大数组?

时间:2013-02-13 15:20:36

标签: php wordpress

我正在处理的网站有很多查询和大量相同的日常内容。人们想到的只是先创建一个大型阵列,然后在之后将其切片?

我认为让PHP做更多的工作并让MySQL有点休息是很快的。

思想?

 $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() as $tag){
    $tags[]=$tag->name;
 }

 // Get the Categories
 foreach(get_the_category() as $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(); 

0 个答案:

没有答案