Programmatically change post templates?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://wordpress.stackexchange.com/questions/24924/wordpress-programmatically-change-post-templates">Wordpress - Programmatically change post templates?</a>  </p>
</blockquote>



<p>I need to change the template on several hundred pages on my site. Does anyone know if there is a command to do it programmatically? See the following code snippet; I'd like to replace my comment inside the loop with a function that will change the template of the current page:</p>

<pre><code>query = new WP_Query($args);
while ( $query-&gt;have_posts() ) : $the_query-&gt;the_post();
  if ( has_tag('tag-slug') )
  {
     /* CHANGE TEMPLATE OF $post */
  }
endwhile;
wp_reset_postdata();
</code></pre>
