Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Kevin Cooper21,294 Points
Advanced Custom Fields, Displaying certain fields from specific categories
Using the <?php the_field ( 'image' ); ?> as an example, how would I get that field where ever the code is places to only show certain images from specific categories. Can I pass a category to it, like <?php the_field ( 'image', 'windows' ); ?> if so how is that set up in the ACF plugin when creating the field?
Kevin Korte28,135 Points
I'm not sure I understand 100% of what you're trying to accomplish, but according to the ACF documentation, you can pass their function
the_field a post id, option, taxonomy, user, etc.
A category is a type of taxonomy, so in theory, you should be able to pass
the_field a category.
Maybe a use case example might help me more. Or you can play around with it and try it out.
Zac GordonTreehouse Guest Teacher
Are you looking for a field that only lets you select images that have been uploaded and tagged with a certain category?