When I write a post by HTML content then p tag auto-generated under the img tag.
<img class="round-img" src="/single-post-1.jpg" alt="img">
<p></p>
You may remove the automatic P tags by this filter. Place this in functions.php file
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
You could do this:
ADD this script in the page where you want to remove <p></p>
<script>
$( document ).ready(function() {
$('img').closest('p:empty').remove();
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.