WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm learning about caching parameters and tried this in the single.php template:

echo count($wp_object_cache->cache['posts']);

$query = new \WP_Query([
  'post_type' => 'post',
  'cache_results' => false,
  'posts_per_page' => 5,
  'ignore_sticky_posts' => true
]);

echo '<br>' . count($wp_object_cache->cache['posts']);

The result:

3
7

Somehow, the cache_results parameter didn't work. Am I missing something?


I'm using:

  • WordPress version 4.6.
  • Twentyfifteen theme.
  • No plugins/third party services.
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.