WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #18822, comment 5


Ignore:
Timestamp:
09/30/11 12:59:23 (3 years ago)
Author:
F J Kaiser
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #18822, comment 5

    initial v1  
    22> In fact get_post() will only perform a query if you pass an object when the object has the filter property set ''and'' that post ID isn't already cached. 
    33 
    4 If you look closer at the code (in core & on wpse) you'll see that there's the filter name 'sample' required. Default is 'raw'. So, until you don't set the filter to 'sample' manually, you'll get an additional query.  
    5  
    6 > You can also pass the whole $post object to get_permalink for no extra queries as get_post() accepts an object. 
    7  
    8 Sure, but it won't be used until the object hasn't got the appropriate ''filter'' attached. 
     4If you look closer at the code (in core & on wpse) you'll see that there's the filter name 'sample' required. Default is 'raw'. So, until you don't set the filter to 'sample' manually, you'll get an additional query and passing the object to the function won't help anything. Tested this in various cases - see also @scribu work around.