[wp-hackers] can't make sense out of: get_permalink(), $id->filter & 'sample' filter

24/7 24-7 at gmx.net
Mon Sep 19 22:32:16 UTC 2011


I'm currently trying to call all posts in one Query and then attach the 
author object as well as the permalink to the post object. Sadly 
get_permalink(); produced one additional DB query per call. I could manage 
the problem as I found out that a) the Codex and b) the docBlock for 
get_permalink() was wrong: You can pass the whole post object into the 
function. This allows bypassing the following lines [1] - if you attach 
$post->filter = 'sample' to your post object before you drop it into 
get_permalink();.

Now I question: What for do I need $id->filter (which is in this case 
$post->filter), which isn't attached to a post object in a "normal" query.? 
And why can't I bypass the additional call to get_post(); otherwise? Under 
normal circumstances (or simply in a lot of cases) get_permalink(); is 
called inside a loop, so I wouldn't need to get post object again.

Thanks for your time.
K.


More information about the wp-hackers mailing list