How to reduce the database query-es

You can try this version with WP_Query() called only once:

<?php
$args=array( 
    'post_type' => 'stiri',
    'posts_per_page' => 5,
    'taxonomy' => 'stire',
    'stire' => 'articole-speciale'
    );
$recentPosts = new WP_Query($args);
?>
<div id="featured" >
    <ul class="ui-tabs-nav">
        <?php $i=0; while ($recentPosts->have_posts()) : $recentPosts->the_post(); $i++;?>
            <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php echo $i;?>">
                <a href="#fragment-<?php echo $i;?>"><img src="/scripts/timthumb.php?src=<?php the_field('imagine_stire'); ?>&amp;h=50&amp;w=80&amp;zc=1" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" /><span><?php the_title(); ?></span></a>
            </li>
        <?php endwhile; ?>
    </ul>

    <?php $recentPosts->rewind_posts();?>

    <?php $i=0; while ($recentPosts->have_posts()) : $recentPosts->the_post(); $i++; ?>    
        <!-- Stirea <?php echo $i;?>  -->
        <div id="fragment-<?php echo $i;?>" class="ui-tabs-panel" style="">
            <a href="<?php the_permalink() ?>"><img src="/scripts/timthumb.php?src=<?php the_field('imagine_stire'); ?>&amp;h=325&amp;w=664&amp;zc=1" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" /></a>
            <div class="info" >
                <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
                <p><?php $excerpt = get_the_excerpt();echo string_limit_words($excerpt,30);?><a class="detalii" href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Stire %s'), the_title_attribute('echo=0')); ?>">...detalii</a></p>
            </div>
        </div>
    <?php endwhile; ?>
</div>

where $recentPosts->rewind_posts() is used to rewind before the second loop.

Leave a Comment