• Resolved fireflip

    (@fireflip)


    Hey!

    Can anyone point me in a direction to the best way to dynamically relate images to a post?

    I would like to be able to upload images using the media library, tag the images with an assortment of tags and then have those images show up on posts that match those tags.

    So for instance if a post is titled “Holiday” it will display all images that have been tagged with “holiday”.

    Any pointers will be greatly appreciated,
    Thanks!

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

    (@bcworkz)

    Well, the first issue is media attachments do not support tagging. Try examining the global $wp_post_types and see if you can somehow enable support by altering the attachment post type.

    If you can achieve that, the rest should be easy. You create a new WP_Query object to query for post_type attachment and having the particular tags belonging to the current post. Then simply run a secondary loop with the results. Don’t forget to reset the query in the end so the main query can continue.

    Thread Starter fireflip

    (@fireflip)

    Thanks so much! The tagging media atachments part of it is actually taken care of already compliments of a great plugin (WP Media Tagger) but I couldn’t figure out what to do with the tagged images.

    I think your pointers were just what I needed to set me on the right track.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Relate Images to Posts, Advice?’ is closed to new replies.