Place post featured image behind post text in Testimonials plugin
-
I have a working testimonials plugin that uses the existing WordPress post admin backend and its own category list, each testimonial can have a featured image however the plugin does not currently make use of it.
I would like to be able to display the featured image as a background to the main testimonial content area (the body text) with padding to a minimum height (width should be fine) so that a regular aspect photo will look good.
So far I’ve managed to get some jquery working to set the background image using css but not from the testimonial post, it’s just a hard url in the jquery code.
Any help with this would be much appreciated.
Here’s what I have so far in a js file that lives in the child theme folder, this file is successfully being called and added to the footer by functions.php:
(function($) { $('.cms-testimonial-content .content').css("background-image","url('/wp-content/uploads/2018/06/testimonial-featured-image.jpg')"); })( jQuery );
I think what I need to do is get the featured image url from the database and insert it into a variable, but that’s the part I’m fairly clueless about when it comes to jquery and WordPress.
- The topic ‘Place post featured image behind post text in Testimonials plugin’ is closed to new replies.