1

I'm creating a website for a theater company, using Elementor, ACF, CPT UI, and Jet Engine. One custom post type, "productions," includes an ACF gallery of production images. Another Custom Post Type, "artist bios," includes bio and past production information for all artists (about 200 artists in total). Both of these post types use an Elementor single template.

I've been trying to find a way to add a gallery of tagged images (attached to the individual artists' names) to each bio page. The goal is that, as new production images are uploaded, the actors appearing in those images could be tagged, and those tagged images would automatically appear on their bio page gallery.

I've tried setting up a many-to-many relationship between bio pages and media attachments, but that hasn't been successful. I added a relationship field to media attachments, allowing you to select artist bio page(s) to link the images to, but I can't find any way to populate a gallery based on that information.

Any suggestions? I'd like this to be able to be managed automatically and dynamically if possible, given the volume of artists and images involved.

0

I don't use ACF myself, but what you're essentially needing to do is to be able to add a series of tags to images. There's a tutorial here that explains how to do it with ACF: https://www.greengeeks.ca/tutorials/article/add-custom-fields-to-media-wordpress/

You then need to use ACF to add an 'image tag' to the artist profiles. Something that you can use to re-unite the artist with their photo.

So lets say for the artist you have 'gallery-tag' = 'alice-dutton'.

Then for the images, as you upload them, you fill out 'artist-tags' = 'alice-dutton'.

Two artists? 'artist-tags' = 'alice-dutton', 'steve-buscemi'

So basically the way page, post, category and tag slugs work.

Once you have that set-up in a manner that works for you, on the actual Artists page, you'd have to run a query for attachements that have an artist-tag that matches the artists gallery-tag.

As a standard WP_Query it would look like this:

$gallery_tag = get_post_meta( $post->ID, 'gallery-tag', true ); //this would get 'alice-dutton'

$gallery_qquery = new WP_Query( array(
    'post_type'         => 'attachement',
    'posts_per_page'    => -1, //gets all of them
    'meta_query'        => array(
        array(
            'key'           => 'artist-tag',
            'value'         => $gallery_tag 
        )
    ),
) );

And then you'd run your output for the $gallery_query.

You'll have to go through the ACF and Elementor documentation to sort out exactly how to do it - I've never built a full project with either and have work with them very, very few times. But from my reading this shouldn't be a problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.