[wp-hackers] When $posts = 1
David Clark
david at davidsaccess.com
Sun Dec 19 19:41:32 UTC 2004
Hi,
I can't seem to find the thread, but Michael rose the issue a while
back in the specific case of a search that returns one, result --
having it return are actual post rather than the results page. I want
to generalize this to work for any listing that only has one result.
I have tried the following, with no luck:
function one_listing_template() {
global $posts;
if (1 == count($posts)) {
load_template(get_template_directory() . '/single.php');
exit;
}
}
add_action('template_redirect', 'one_listing_template', 1);
any ideas?
dc
More information about the hackers
mailing list