WordPress.org

Forums

Playing with custom queries and cache_results - false (3 posts)

  1. mayuxi
    Member
    Posted 1 year ago #

    Dear collective mind,

    I'm trying to speed up my blog, where I have many custom queries made with WP_Query. Today I found out about "Caching Parameter" (cache_result and others) and want to give it a try. It says:

    In general usage you should not need to use these, adding to the cache is the right thing to do, however they may be useful in specific circumstances. An example of such circumstances might be when using a WP_Query to retrieve a list of post titles and URLs to be displayed, but in which no other information about the post will be used and the taxonomy and meta data won't be needed. By not loading this information, you can save time from the extra unnecessary SQL queries.

    Question: So, does it mean I can use this parameters to optimize my query in case where I just show titles with link from custom post type on my front page?

    Example:

    $args = array(
    			'post_type' => 'outside',
    			'posts_per_page' => 5,
    			'ignore_sticky_posts' => 1,
    			'no_found_rows' => 1
    	);
    	$second_query = new WP_Query( $args );
    <?php while( $second_query->have_posts() ) : $second_query->the_post(); ?>
    
    	<li>
    		<a href="<?php echo get_permalink(); ?>" rel="nofollow"><?php the_title(); ?></a>
    	</li>
    <?php endwhile; wp_reset_postdata(); ?>

    Thanks!

  2. mayuxi
    Member
    Posted 1 year ago #

    No replies yet? Fuuuu... :) Anybody?

  3. mayuxi
    Member
    Posted 1 year ago #

    Wow, probably I should try another board?

Topic Closed

This topic has been closed to new replies.

About this Topic