I’m trying to figure out the best / most efficient way to populate several dropdowns on an archive page of a custom post type. The post type is images and the archive page obviously displays a list of images… each image has various custom fields such as author, area of research and instrumentation etc ( which act a little like taxonomies but are actually other custom post types ).
What I want to do is populate some drop downs to act as front end filter options with unique arrays ( no repeats ) for all the values of each custom field attached to the image post types. The querying / filtering / url get value functionality is all sorted. I just want a neat way of populating these drop downs.
I could of course call WP_Query to fetch all the images post type data and loop through building arrays of custom fields, then calling array_unique and then looping back through to populate the selects. However, I feel this is way too much php processes and possibly overkill, especially considering I then need to the for main loop to build the page as well.
Another way would be to call WP_Query on the filtering post types ( author, area of research and instrumentation etc ) and do it that way, but then there might be some of these that are not attached to any images.
Is there any neat acf or wordpress functions that I don’t yet know of yet to achieve something like this?
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users