Support Forum

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Set background colour with acf field value Reply To: Set background colour with acf field value

#5956
Paul
Participant

Hey Tom

Still trying to get a custom background colour behind each WPSP item. The adjustment above didn’t work, unfortunately.

As an alternative, I’m trying to insert a div with a custom colour background behind each block using the wpsp_before_wrapper hook like this:


add_action( 'wpsp_before_wrapper','wpsp_add_custom_meta' );
function wpsp_add_custom_meta()
{
    $meta = get_post_meta( get_the_ID(), 'background_colour', true );
    if ( isset( $meta ) && '' !== $meta )
	echo '<div style="background-color:' . $meta . '">';
}

add_action( 'wpsp_after_wrapper','wpsp_close_div' );
function wpsp_close_div()
{
	echo '</div>';
}

This doesn’t work – nothing gets inserted. However, replacing wpsp_before_wrapper with wpsp_before_header and wpsp_after_wrapper with wpsp_after_content DOES insert a div with a custom background colour behind the header and content. Not quite what I want, but proves the custom field is working. Just need to target the right element.

The staging page is here: https://actondemo47.com/news-list/
Any ideas?

Thanks
Paul