Archived topic
Hook/Shortcode for containers dynamic background image
1 reply · Started by Oliver on March 21, 2021
With GP alpha 5, i have an page hero element for a wordpress archive. Hook name is after_header.
Included is one Container with a static, fix background image.
Now i want to exchange this background image, dependent from a GET-Parameter.
Is there a way to do this with a shortcode instead of a fully qualified filename? Is there an appropriate hook or waht would be the best way to do this with GP container?
Thanks for any hints.
Hi there,
There's no hook for stylesheets but you should be able to assign that dynamic value (PHP or JS) with a script using the Hook Element.
If you're PHP, make sure "Execute PHP" is enabled.
Example code: (PHP, from a ACF)
<?php
$backgroundIMG = get_field('bg_acf_url');
echo '<style>
.target-element-class { background-image:'. $backgroundIMG .'; }
</style>';
?>