[wp-hackers] get_post() not fetching from post cache after update_post_caches()

William Canino william.canino at googlemail.com
Thu Oct 1 16:47:22 UTC 2009


I'm coding a Yet-Another-Clickable-List-of-Posts-With-Something-in-Common.
 The amount of SQL queries my current code is making is driving me
nuts.

2009/10/1 scribu <scribu at gmail.com>:
> It looks like a bug.
>
> But why would you manually call update_post_caches?
>
>
> On Thu, Oct 1, 2009 at 8:39 AM, William Canino <
> william.canino at googlemail.com> wrote:
>
>> WordPress wizards, would you have a look at this code:
>>
>> $my_query = new WP_Query(array('post__in' => array(1,2,3)));
>> update_post_caches($my_query->posts);
>> echo $get_permalink(1);
>> echo $get_the_title(2);
>>
>> Do you know why WordPress is still making SQL queries on lines 3 and
>> 4? Shouldn't they be already in the object cache?
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>
> --
> http://scribu.net
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list