How to dynamically populate a Wordpress page with images selected by a filter?

I have installed two plugins; Envira Gallery (Lite version) and ACF (Advanced Custom Fields).
The Wordpress site I'm building is intended to be a aircraft gallery so I have added an ACF field to each image to identify the aircraft type. I would like to have a page that is passed the value of aircraft type which is then used to populate the page with all the images of that type.
New to Wordpress so I don't know if this is possible.
ClintonKAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Peter HartCommented:
are the aircraft only filtered by aircraft type?
if so, you could simply create albums in Envira for each aircraft type
and use short codes to simply display each album (aircraft type)  on a separate page for each one.
0
Alicia St RoseOwner & Principle Developer/DesignerCommented:
You can also add the shortcode to your template file so that this dynamically happens for you. You'd have to make a child theme of your current theme and pull the template you will be editing into your child theme. Have you created a custom post type: Aircraft? And a custom taxonomy: Aircraft Type. This would be the best way to go about this. Otherwise, you could use a portfolio theme and use the Portfolio post type for you aircraft. Whatever you decide you'll probably be editing the taxonomy.php file to place your gallery shortcode.

I do this quite often.

1. Create Custom Post Type: Aircraft (register as aircraft)
2. Create Custom Taxonomy: Aircraft Type (register as aircraft-type)
3. Create ACF custom fields
4. Create template file: single-aircraft.php
5. Copy contents from single.php into it
6. Pay heed to the LOOP is it says something like this:
<?php
			while ( have_posts() ) : the_post();

				get_template_part( 'template-parts/content', get_post_format() );

			endwhile; // End of the loop.
			?>

Open in new window

Then you simply follow the path "template-parts/content.php" in parent theme. Create that folder in your own theme.
7. Create a file in that folder called: content-aircraft.php
8. Copy content from parent content.php into it.
9. Return to single-aircraft.php and change
get_template_part( 'template-parts/content', get_post_format() );

Open in new window

to
get_template_part( 'template-parts/content', 'aircraft' );

Open in new window

10. Now you can edit the single view of your aircraft to your hearts content.
11. But, you still need the gallery and archive
12. Since you are showing the aircraft by type, you will need to grab the taxonomy.php, if your theme has one. (Hopefully, you are starting with Underscores. Best started theme EVER!! And no need for child theme!)
13. You can create taxonomy-aircraft-type.php in your child theme folder.
14. Copy content from parent theme taxonomy.php or archive.php if taxonomy is missing...
15. Once again,  you will want to edit the loop. This is where you are going the add the gallery shortcode. You add it to templates in this manner:  
echo do_shortcode( '[iscorrect]' . $text_to_be_wrapped_in_shortcode . '[/iscorrect]' );

Open in new window

Your's will look like this:
<?php echo do_shortcode(get_field( 'field_name' )); ?>

Open in new window

You will be placing the shortcode in the field and it will be echoed in the template.

I'm rendering the gallery on Projects for a client site. Here you see a single view with gallery at top:

http://sandbox.intrepidrealist.com/alan-macy/project/heartbeat-amplifier/

I'm using the same: Advanced custom fields and envira Gallery.

Backend:

Edit-Project---Alan-Macy---WordPress.jpg
So, a lot of what I outlined above may be over your head right now, but it's easily grounded by forays into GoogleLand. Here is a link to the WordPress template hierarchy, once mastered, WordPress is putty in your hands...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ClintonKAuthor Commented:
Thanks Alicia St Rose, that's going to take me a minute or two to digest ;-) but does sound promising from how you describe it.
I'll report back.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

ClintonKAuthor Commented:
After four weeks of working with Wordpress (I started knowing nothing and now I know a little bit more), I think I'm beginning to understand your (Alicia St. Rose) answer.
My four weeks have been spent uploading media and annotating the associated ACF fields with the relevant information about each image, e.g. aircraft type, aircraft registration, serial number of the build etc. etc. I have created a couple of functions that query the media posts and return the images according to the $_GET in the URL. This works OK and although I can display the images in a grid, I don't think I'm easily able to use the pagination plugins that I would if I used a custom post.
I think I've got the method you describe working but as far as I can see, I have to create an Envira Gallery of each of the aircraft types. If for example my aircraft type is D120 then I would need to create an Envira Gallery of all the aircraft of type D120. I would need to create another gallery of all aircraft of type D150 etc. etc.
Have I understood this correctly?
0
Alicia St RoseOwner & Principle Developer/DesignerCommented:
Hi ClintonK! Sorry about the delay.

Yes, create a gallery for each aircraft type and put the short code in the field. Make sure you are using that custom field in the do_shortcode function in your theme. Also, you may want to play around with the configurations in Envira. It's pretty much the only thing you can play with on the free version. You can set how many images you want in columns and what size the thumbs should be. You can't do this globally, but for each gallery. Maybe premium version allows global settings for all galleries..
0
ClintonKAuthor Commented:
Thanks for the very detailed suggested solution to my problem. I implemented a variation of your solution by using Custom Posts to create data with which i can populate and sort arrays of images which I then display in a foreach loop. This allows me to dynamically display the media library.
1
Alicia St RoseOwner & Principle Developer/DesignerCommented:
That's awesome ClintonK!!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.