dimanche 29 mars 2015

Accessing post data before functions.php in Wordpress

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.


I managed to rewrite template hierarchy using conditional tags but got stuck on functions.php


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().


I could only find a trace of a solution with custom db queries, $wpdb etc. but can't really figure it out.


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?


To illustrate what I'm writing about I pasted my main index.php





<?
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();

?>



Thanks!


Aucun commentaire:

Enregistrer un commentaire