3

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?

2 Answers 2

10
function add_image_class($class){ $class .= ' additional-class'; return $class; } add_filter('get_image_tag_class','add_image_class'); 
-2

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

$(document).ready(function() { $("img").addClass("myimg") }); 
2
  • is there a way to do this via PHP or a WP function rather than JS? Commented Aug 3, 2013 at 9:59
  • The better way is not php or wordpress for all images. Commented Aug 3, 2013 at 10:04

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.