I want to add a CSS class "myimg" to every image both inside and outside of a post. What is the best way to approach this?

function add_image_class($class){
    $class .= ' additional-class';
    return $class;

Try to use this j query function like this in header file

$(document).ready(function() {
  • is there a way to do this via PHP or a WP function rather than JS? – manc Aug 3 '13 at 9:59
  • The better way is not php or wordpress for all images. – Bindiya Patoliya Aug 3 '13 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.