You need to hook wp_add_inline_style
to wp_enqueue_scripts
. Check the codex example. Something like (not tested):
function lethal_post_circle_background(){
global $post;
$id = $post->ID;
$custombgcolor = get_post_meta( $id, 'bgcolor', true );
$custombgimage = get_post_meta( $id, 'bgimage', true );
if($custombgcolor | $custombgimage){
$css=".post-".$id.' .post-circle{
background:';
if($custombgcolor) $css .= $custombgcolor . ' ';
if($custombgimage) $css .= 'url("' . $custombgimage . '")';
$css.= ';}';
wp_add_inline_style('lethal-style', $css);
}
}
add_action( 'wp_enqueue_scripts', 'lethal_post_circle_background' );