[wp-hackers] the right hook for custom content
Austin Matzko
if.website at gmail.com
Tue Mar 17 14:17:33 GMT 2009
On Tue, Mar 17, 2009 at 8:49 AM, Malaiac <malaiac at gmail.com> wrote:
> I'm looking for the right place to hook for pages like
> www.site.com?custom_content_id=3
> add_action('parse_query') does not work when there is nothing in the query
>
> adding 'custom_content' as a query var ( fill_query_vars) could be
> good, but there is no action between fill_query_vars and the main
> parse_query process
> a manual $wp_query->fill_query_vars(array('custom_content','custom_content_id'))
> on init does not work either.
What I do for situations like this is add a rewrite tag for the query
var, in a callback for the init action.
add_action('init', 'my_init');
add_action('parse_query', 'my_parser');
function my_init() {
global $wp;
$wp->add_query_var('custom_content_id');
}
function my_parser() {
$custom_query_var = get_query_var('custom_content_id');
if ( ! empty( $custom_query_var ) ) {
[ do stuff ]
}
}
More information about the wp-hackers
mailing list