Forum Replies Created
-
AuthorPosts
-
Paul
ParticipantPerfect, thank you, Tom!
Paul
ParticipantHi Tom
Do you perhaps have a WPSP beta with the carousel function working that I can play with?
Thanks
PaulPaul
ParticipantSorry mate, that didn’t work either. No worries though, solved by creating a new div inside wp-show-posts-inner with the custom background colour and adjusting styles of both containers.
This is what I wanted the blocks to look like:
https://actondemo47.com/news-list/Cheers
PaulPaul
ParticipantBTW, I assumed the hook ‘wpsp_before_wrapper’ refers to the wrapper element around each individual post block, but I guess I’m wrong. I’ve set the news page: https://actondemo47.com/news-list/ to insert a div with a custom colour behind the header and content temporarily so you can see that the code works, but doesn’t make the whole block a custom background colour.
Paul
ParticipantHey 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
PaulPaul
ParticipantSadly, no go – used a media query hack to show a different version of the WPSP block on IE only.
Thanks anyway, Tom
Paul
ParticipantHey Tom — alternate idea:
I can solve this if you can show me how to add the class “.news” to the wp-show-posts-inner element.
Please let me know.
Thanks
PaulPaul
ParticipantSorry Tom, that snippet didn’t work. I substituted my actual acf field name ‘background-colour’ for ‘_my_color’. I then tried setting $color = ‘#666’ to see if a hard-coded hex value would work in case acf wasn’t being set — this added a background colour to the whole wpsp wrapper, not behind each individual item (wp-show-posts-inner).
Is there another way to dynamically set the background colour of each wp-show-posts-inner element to an acf value from the post?
Thanks
PaulPaul
ParticipantAwesome! Looking forward to it. Appreciate the amazing work you’re doing on WPSP and GeneratePress.
Cheers
Paul -
AuthorPosts