query_posts需要一段时间才能加载


query_posts taking a while to load

我创建了一个简单的WordPress网站,但加载需要一段时间。我过滤掉了所有的帖子,只显示那些带有front:标签的帖子

<?php 
query_posts( 'tag=front' );
while ( have_posts() ) : the_post(); 
    ?>

我知道这可能是一种不好的做法。如果是,为什么?有没有一个简单的替代方案?

试试这个:

<?php
    $paged = ( get_query_var('paged') ) ? get_query_var( 'paged' ) : 1;
    $args = array(
        'tag' => 'front',
    );
    $front_query = new WP_Query( $args );
    global $more;
    if ( $front_query->have_posts() ) :
        while ( $front_query->have_posts() ) : $front_query->the_post();
            $more = 0;
    ?>
                <h1><?php the_title(); ?></h1>
                ....
                ....
                ...
    <?php   
        endwhile;
    else :
        get_search_form();
    endif;
?>