Rewrite loading custom template file but is_home() returns true, and there’s no 404

Conditional variables are based on the main page query ($wp_query). If you want is_home() to be false, then you need to manually set it to false ($wp_query->is_home = false) or override the main query such that it’s not true anymore. Probably you’d do that in your template_redirect_intercept function there, or in the individual page templates you’re making using query_posts().

For your second problem, you have two main issues.

  1. template_redirect_intercept is exiting indiscriminately. It doesn’t care what the return value of the output function call is.

  2. Returning the results of “is_404” is probably useless since the main query thinks it’s returning the home page, not a 404. What you want to do here is to call $wp_query->set_404() if the page is supposed to not exist, then return something that will cause template_redirect_intercept to not exit. You want that function to return in that case, thus allowing the normal 404 handler to take over.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)