I'm having a problem with a plugin that I've been developing. The problem is that the plugin breaks the ability to preview a post, whether it's in draft or published. It simply brings up Wordpress's 404 page. I haven't been able to track down the problem, so I'm coming to you to ask for ideas - possibilities that could cause this behaviour. I'm not going to post any code here, the plugin spans many files and is several thousand lines of code long, so I'll give a brief description of the kinds of things the plugin does.
Firstly, it creates some new Post Types. Secondly, it sets up some rewrite rules (using add_rewrite_rule) and adds a few query vars (they are all prefixed and unique). Thirdly, it hijacks the request and sets up some data IFF one of those query vars is set. Finally, it hijacks the template selection process to inject posts of certain post types in custom templates.
I've ensured my Post Types are publicly_queryable, however, the problem also affects regular Posts (non-custom post-types). I've tried to go through and isolate what might be causing the problem, but I can't find anything.
Here is one piece of code that I have been looking at a little more closely than others:
if(is_preview())
{
$query->set('post_type', get_post_types(false,'names') );
}
else if (is_home() && $query->is_main_query())
{
$query->set('post_type', array("post", "review", "article", "interview", "preview", "news"));
}
return $query;
I read somewhere, something, about setting the post_type query var this way if it's a preview, but it's had no effect.
So, any ideas? Thanks alot!