not in the file.css but you can use inline css to get the custom background. Assuming your image field is getting the file url, you can use a code like the one below to change the background.
<?php if( get_field( "your_field") ): ?>
<style>
.custombackground { background-image: url(<?php the_field('your_field'); ?>); background-repeat: no-repeat; }
</style>
<?php endif; ?>
This code should be inserted in the header.php file before the </head> tag.
Thread Starter
Olybop
(@olybop)
yes that’s perfect. Thx you 😉
In this exemple you have a dynamic background with a custom post field :
<style>
.header {
background: transparent url(<?php echo get_post_meta($post->ID, 'wpcf-mycustompostfield', true); ?>) no-repeat center center ;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>