We can use jQuery to wrap the images under the specified class with a div having the class image-container. Here's a jQuery script to achieve this:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
jQuery(document).ready(function($) {
// Find images within the specified class
$(".single-post img").each(function() {
// Create a new div with the class 'image-container'
var imageContainer = $("<div>").addClass("image-container");
// Wrap the image with the new div
$(this).wrap(imageContainer);
});
});
</script>
This script uses jQuery to target all img elements within elements with the class .single-post and wraps each image with a div having the class image-container.
Make sure to include this script on the page where you want this behavior to occur. You can place it in the HTML's <head> section or before the closing </body> tag, depending on your website's structure and requirements.