title: Accessing post data before functions.php in Wordpress
body: <p>I am updating my custom Wordpress theme, but as it is rather time consuming process I would like to launch one section at a time. 
  In other words there would be several versions of a theme for different parts of the website.
  To keep things tidy I would like to keep them in separate folders, with all the assets such as js, images, css.</p>
  
  <p>I managed to rewrite template hierarchy using conditional tags but got stuck on functions.php</p>
  
  <p>I was trying to use custom filed (post meta) to switch between several functions.php files but unfortunately $post is not available there so I am unable to use get_post_meta().</p>
  
  <p>I could only find a trace of a solution with custom db queries, $wpdb etc. but can't really figure it out. </p>
  
  <p>Is there any fairly simple solution to hook-up into post data (wp_query) before functions.php is loaded? Or to somehow differently modify where the functions are loaded from?</p>
  
  <p>To illustrate what I'm writing about I pasted my main index.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?
  get_header();
  
  /*
   * Get theme version according to the custom field 'section'
   */
   
  if( function_exists ( 'theme_version' ) ){
   $theme = theme_version( @get_the_ID() );
  } else {
   $theme = 'v2';
  }
  
  include_once( 'theme/'. $theme .'/TEMPLATE_BUILDER.php' );
  
  
  get_footer();
  
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks!</p>