#place this code on top of functions.php, before the framework is loaded
if(!function_exists('avia_get_meta'))
{
function avia_post_meta($post_id = '', $subkey = false)
{
//if the user only passed a string and no id the string will be used as subkey
if(!$subkey && $post_id != "" && !is_numeric($post_id) && !is_object($post_id))
{
$subkey = $post_id;
$post_id = "";
}
global $avia, $avia_config;
$key = '_avia_elements_'.$avia->option_prefix;
$values = "";
//if post id is on object the function was called via hook. If thats the case reset the meta array
if(is_object($post_id) && isset($post_id->ID))
{
unset($avia_config['meta']);
$post_id = $post_id->ID;
}
if(!$post_id)
{
$post_id = get_the_ID();
}
if(!is_numeric($post_id)) return;
if(!isset($avia_config['meta']))
{
$avia_config['meta'] = avia_deep_decode(get_post_meta($post_id, $key, true));
}
if($subkey && isset($avia_config['meta'][$subkey]))
{
$meta = $avia_config['meta'][$subkey];
if($subkey == 'slideshow')
{
if(empty($meta[0]['slideshow_image']))
{
$post_thumb_id = get_post_thumbnail_id($post_id);
if(is_numeric($post_thumb_id))
{
$meta[0]['slideshow_image'] = $post_thumb_id;
}
}
}
}
else
{
$meta = false;
}
return $meta;
}
add_action('the_post', 'avia_post_meta');
add_theme_support( 'post-thumbnails' );
function avia_get_meta(){}
}