Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #715398

    Hi
    I’ve added a fullscreen-background to my page with the following code in my Child Theme style.css:
    .container_wrap_first {background-image: url(https://localhost/wordpress/wp-content/uploads/2016/09/PicName.jpg); background-size: contain; background-repeat: no-repeat;}
    Works perfectly fine so far.

    Now I would like to replace above url with the respective post image url. Achieving the url should be possible with
    <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'full') ); ?>

    My question is: How do I get the url retrieved with php into the css so that the page acutally displays the post image as background?

    Thanks for your help!
    Tim

    #715733

    Hi Tim,

    PHP is not accepted in CSS so I think you would have to add the CSS inline instead so that you can use PHP within it.

    Best regards,
    Rikard

    #715791

    Thanks Rikard!
    So how can I get the CSS inline the html code via php considering that I’m using a child theme. Is there a specific php-filter that I can use for this purpose?
    Thanks for your help!
    Best,
    Tim

    #716118

    Hi,

    Can you please elaborate on the changes you would like to make and post FTP and WP admin logins here privately?

    Best regards,
    Yigit

    #716206

    Hi Yigit,
    please see Private Content section below.
    Thanks a lot,
    Tim

    #716683

    Hey!

    You have to modify the single.php file template directly and add the modification as inline css. Are you using the advance layout builder for posts or just the default editor? If you’re using the default editor, edit the single.php file, look for this code:

    <div class='container_wrap container_wrap_first main_color <?php avia_layout_class( 'main' ); ?>'>
    

    Cheers!
    Ismael

    #719188

    Perfect! Thanks!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘How to render image url with php into css as background-image?’ is closed to new replies.