[wp-hackers] Re: $single
Ryan Boren
ryan at boren.nu
Sun Jun 20 22:32:47 UTC 2004
> Here's what I have:
>
> is_single()
> is_date()
> is_category()
> is_author()
> is_archive() = date || category || author
> is_search()
> is_feed()
>
> These return true or false.
Some people have asked for this code, so here it is. WP_Query_State is
a class that holds the states. If you pass a query string to its
constructor or to its parse_query method, it will set the states
appropriately. I create a global $wp_query_state instance and have
is_single() and friends use that. You can include the attached file
from wp-blog-header.php and call
$wp_query_state->parse_query($query_string) to get the states set.
If we were to put this in WP, I would probably create a classes.php as a
counterpart to functions.php that would contain WP_Query_State and
possibly other small classes. Each class would have a global instance
created by default that template tags could use. I would put
is_single(), etc. in template-functions-general.php, most likely. Or
maybe just in functions.php.
Ryan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wp_query_state.php
Type: application/x-php
Size: 3286 bytes
Desc: not available
Url : /pipermail/hackers_wordpress.org/attachments/20040620/dfb3670b/wp_query_state.bin
More information about the hackers
mailing list