Is there an is_homepage() type of function? And/or perhaps one that shows whether you are on the homepage, a post, a page, a category, an archive, etc.?
Is there an is_homepage() type of function? And/or perhaps one that shows whether you are on the homepage, a post, a page, a category, an archive, etc.?
See Conditional_Tags
Also not related but of interest:
https://core.trac.wordpress.org/ticket/6801
Thank you.
Actually I'm having an issue trying to use is_front_page() within a plugin. The function fails at the "is_page(get_option('page_on_front'))" step, because it seems that the global $wp_query is NULL? So is_page() returns FALSE.
How might I deal with $wp_query being NULL within the plugin?
For some templates it has been necessary to use
wp_reset_query();
Sorry for the late response, but wp_reset_query() does not help. I also tested using the default theme. global $wp_query is still NULL within the plugin.
I was able to get this working by adding query_posts() after wp_reset_query().
wp_reset_query();
query_posts();
However I'm not sure what to put as an input to query_posts(), and without any input I get the warning "Warning: Invalid argument supplied for foreach() in /home/.../wp-includes/query.php on line 1401"
What argument should I be givnig to query_posts()?
Try
query_posts($query_string);Thanks again but that doesn't quite work. global $query_string is blank even after wp_reset_query(). So I get the same warning.
I tried passing globals wp_the_query and wp_query as well.
I can just suppress the warning, but I'm not sure if I'll get some unforeseen bugs later if I don't pass a valid argument to query_posts().
This topic has been closed to new replies.