Support

Account

Home Forums General Issues Post and category image background Reply To: Post and category image background

  • I would imagine something like the bellow would resolve this issue but it doesn’t:

    
        if ( get_field('background_image') ) {
    
        	// set this to the handle of one of your stylesheets
        	$handle = 'main-styles';
    
    	    $queried_object = get_queried_object();
    
    	    if (isset($queried_object->ID)) {
    	    	$post_id = $queried_object->ID;
    	    } else if (isset($queried_object->term_id)) {
    	    	$post_id = $queried_object->taxonomy.'_'.$queried_object->term_id;
    		}
    
        	$bg_image = get_field('background_image', $post_id);
        	$css = "body { background-image: url('$bg_image')!important; }";
        	wp_add_inline_style( $handle, $css );
        }