Skip to main content
added 22 characters in body
Source Link
cjbj
  • 15k
  • 16
  • 43
  • 90

The function get_post_type returns the type of the current post, so supposing you want to add this class only to a post type called 'wpse' you should include a conditional like this:

function add_image_classwpse237573_add_image_class($class){ if ('wpse' == get_post_type()) $class .= ' additional-class'; return $class; } add_filter('get_image_tag_class','add_image_class''wpse237573_add_image_class'); 

The function get_post_type returns the type of the current post, so supposing you want to add this class only to a post type called 'wpse' you should include a conditional like this:

function add_image_class($class){ if ('wpse' == get_post_type()) $class .= ' additional-class'; return $class; } add_filter('get_image_tag_class','add_image_class'); 

The function get_post_type returns the type of the current post, so supposing you want to add this class only to a post type called 'wpse' you should include a conditional like this:

function wpse237573_add_image_class($class){ if ('wpse' == get_post_type()) $class .= ' additional-class'; return $class; } add_filter('get_image_tag_class','wpse237573_add_image_class'); 
Source Link
cjbj
  • 15k
  • 16
  • 43
  • 90

The function get_post_type returns the type of the current post, so supposing you want to add this class only to a post type called 'wpse' you should include a conditional like this:

function add_image_class($class){ if ('wpse' == get_post_type()) $class .= ' additional-class'; return $class; } add_filter('get_image_tag_class','add_image_class');