• I’m trying to add to my images “class=pinthis” to only certain post categories.

    I know I should be doing this through functions.php but can’t figure out where to hook.

    Basically any image (except maybe if the class contains wp-smiley) in a post with a category of “Cooking” I want to append the “pinthis” to whatever is in the <img class=”xxxx” ….. IE <img class=”xxxx pinthis” where xxxx was whatever was there before.

    All other posting categories I want to exclude from adding this class.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    To hook the HTML inserted into post content by the add media modal, use the ‘media_send_to_editor’ filter. Your callback is passed the attachment ID as the second parameter, from this you can determine the parent post ID and what categories are assigned.

    Thread Starter GoodOmens

    (@goodomens)

    Thanks – I’ll look into that class.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding custom image class to only certain categories?’ is closed to new replies.