[wp-hackers] hooks on the Loop
Dan Kuykendall
dan at kuykendall.org
Thu Jul 13 01:42:23 GMT 2006
You may want to look at what Im doing in podPress.
function filter_the_posts($input) {
$result = array();
if(!is_array($input)) {
return $input;
}
foreach($input as $value) {
$value = $this->addPostData($value);
if(!defined('PODPRESS_PODCASTSONLY') || !empty($value->podPressMedia)) {
$result[] = $value;
}
}
return $result;
}
If dealing with wordpress 2.x you used
add_action('the_posts', 'filter_the_posts');
for WP 1.5
add_filter('the_posts', 'filter_the_posts');
I changed the function names to make this easier to understand.
What I do is loop thru the list of posts and filter out the ones I want
to. Theres no reason you couldnt do the same thing
Aaron Brazell wrote:
> On 7/12/06, Andy Skelton <skeltoac at gmail.com> wrote:
>>
>> No... you should start dissecting WP_Query with your own two hands.
>> It'll be a lot less confusing when you find out what's actually being
>> passed around by these filters and how you can affect the process.
>>
>> Try something like die(print_r($this->request, true)) just before the
>> get_results call (maybe line 921) of query.php.
>>
>> No amount of advice from me or someone else can compare to a little
>> first-hand experience.
>>
>>
> Thanks, Andy. I appreciate it. But you know... I've dissected WP_Query and
> can't find a real reasonable way to get posts that have recent comments.
> Heck, even if there was a way to pass a direct query to query_posts() I
> could work up some query similar to the dozen and a half "recent comments"
> plugins, but I don't even think I can directly pass SQL.
>
--
Dan Kuykendall (aka Seek3r)
http://www.mightyseek.com
In God we trust, all others we virus scan.
Programmer - an organism that turns coffee into software.
More information about the wp-hackers
mailing list