title: Wordpress plugin generating virtual pages and using theme template
body: <p>I have a need to be able to generate fake/virtual/dynamic pages based on a url like <a href="http://www.mycinema.com/wpcinema/movie/MOVIEID" rel="noreferrer">http://www.mycinema.com/wpcinema/movie/MOVIEID</a> to be able to display movies for cinemas with info on the movie and live session feed information.</p>
  
  <p>After spending many hours researching, there doesn't seem to be much stuff written on how to do virtual pages in WordPress, so I will be writing up my experiences after getting this resolved!</p>
  
  <p>So far, the current plan is to use the two filters - template_redirect to set the template  to the current plugin's page.php template, and the_content to insert the content.  The idea is to use the theme's template so the pages theme in well with the site.</p>
  
  <p>(I got this approach from <a href="http://xaviesteve.com/2851/generate-a-custom-fakevirtual-page-on-the-fly-wordpress-plugin-development/" rel="noreferrer">this excellent 2012 page from Xavi Esteve</a>).</p>
  
  <p>I have two problems:</p>
  
  <ol>
  <li><p>What is the best, most bullet proof, way to do this?  Am I using the wrong approach?  My thinking was that using the current theme's template was likely to provide the best current fit for the style of the website.</p></li>
  <li><p>TwentyTwelve does not appear to be calling the the_content filter in the context I'm using it.  I suspect I'm doing something wrong, but cannot find the problem.  This is probably closely related to question 1.  TwentyTwelve definitely calls the_content for a normal page, and even an early add_filter() doesn't trigger in my code.</p></li>
  </ol>
  
  <p>I discovered get_template_part() yesterday and wondered if I should be using that instead of manually looking in the child folder then the parent and running an include.</p>
  
  <p>I wouldn't be asking, but I'm at my wit's end having googled extensively, possibly for the wrong search terms.</p>
  
  <p>I've considered custom post types, but there are various complexities around this (including content that may change every few minutes) which means a dynamically generated page works much better.</p>
  
  <p>This is an excerpt from the code I've written to explain the problem further:</p>
  
  <pre><code>add_action('parse_request', array(&amp;$this, 'vm_parse_request'));
  
  function vm_parse_request( &amp;$wp )
  {
      global $wp;
      if (empty($wp-&gt;query_vars['pagename']))
          return; // page isn't permalink
  
      $p = $wp-&gt;query_vars['pagename'];
  
      if (! preg_match("#wp-cinema/movie/([^/]+)#", $p, $m))
          return;
  
      // setup hooks and filters to generate virtual movie page
      add_action('template_redirect', array(&amp;$this, 'vm_template_redir'));
      add_filter('the_content', array(&amp;$this, 'vm_the_content'));
  }
  
  function vm_template_redir()
  {
      // Reset currrently set 404 flag as this is a plugin-generated page
      global $wp_query;
      $wp_query-&gt;is_404 = false;
  
      $template = 'page.php';
  
      include(STYLESHEETPATH."/page.php"); // child
      // parent case left out for brevity
  
      exit;
  }
  
  
  function vm_the_content($content)
  {
      return "my new content (actually generated dynamically)";
  }
  </code></pre>
  
  <p>This is going to be an increasingly common thing in WordPress - can anyone offer suggestions or help?  Anything is much appreciated.</p>