I ended up having to go about this another (better) way.
In functions.php:
function F_custom_fields($need)
{
// The Loop all on one line
if (have_posts()) : while (have_posts()) : the_post(); endwhile; endif;
// Get all of the custom items from the wp_postmeta table for this post/page
$custom_fields = get_post_custom();
// Return the needed custom item, if it exists
if ($need == 'page_icon')
{
$page_icon = $custom_fields['eva_page_icon'][0];
if (!empty($page_icon))
{
return $page_icon;
}
else
{
return FALSE;
}
}
else if ($need == 'div_id')
{
$div_id = $custom_fields['eva_div_id'][0];
if (!empty($div_id))
{
return $div_id;
}
else
{
return FALSE;
}
}
}
In header.php:
$begin_div_id = F_custom_fields('div_id');
if ($begin_div_id)
{
echo '<div id="'.$begin_div_id.'">'."\n";
}
And in footer.php (to close the div tag started in header.php:
$end_div_id = F_custom_fields('div_id');
if ($end_div_id)
{
echo '</div>';
}