WordPress.org

Ready to get started?Download WordPress

Forums

If post has this tag Then add class to thumbnail (3 posts)

  1. chrisanthropic
    Member
    Posted 1 year ago #

    I'm working on a custom page template and am trying to accomplish the following.

    If my post has the tag "monkeys" (for example) them I want the class "tag-monkeys" added to the thumbnail so that the proper style is applied.

    I've been messing with it for a bit but haven't had any success. Has anyone else managed something similar?

  2. ronangelo
    Member
    Posted 1 year ago #

    If you added the <?php post_class(); ?> on the posts then it already has the tags as classes. So if thumbnails are inside the article/post tags then your css would be like this:

    .tag-monkeys .thumbnail {}
  3. chrisanthropic
    Member
    Posted 1 year ago #

    Hm. I'm using a custom theme and it looks like they do a lot of crazy calls to/from other files so it's out of the loop. I'll keep picking away at it, thanks though.

Topic Closed

This topic has been closed to new replies.

About this Topic