Remove WordPress autop From Images
I was recently working on a website for a client and was experiencing an odd margin issue with the top of the content. It turns out this was because of the WordPress autop function wrapping an image with a p tag. By default when you insert an image into the content in WordPress it wraps the image in an anchor that links directly to the image itself. This was fine with me and in fact what the client wanted, but that damn paragraph tag was messing up the formatting because of the margin I had set for paragraphs. After some careful Google-fu and failed attempts at modifying the autop filter, I decided upon a jQuery fix that the client and I are both okay with. I’ve included the code below so anyone in the future who has this issue might be helped by this (Google wasn’t too helpful).
Note: Make sure you replace the container (I used #page_whole).