• I got a little code that calls all the posts in the category of the currently viewing post

    it is as followes

    <ul>
    <?php
    foreach( ( get_the_category() ) as $category ) {
    $the_query = new WP_Query('category_name=' . $category->category_nicename . '&showposts=-1');
    while ($the_query->have_posts()) : $the_query->the_post();
    ?>
    			<li>
    				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a>
    			</li>
    <?php endwhile; ?>
    <?php
    }
    ?>
    </ul>

    some categories have 500+ posts, and this is a very slow query

    anyway to make it more efficient? or at least make it load last or separately so it does not affect the overall loading time of a page?

The topic ‘Optimize this Php call?’ is closed to new replies.