Home › Forums › Front-end Issues › Linking Custom Fields – Tag or Archive Layout
Have searched but can’t find an appropriate response.
I’m wanting to link some of my custom fields so that when clicked, an archive page of all posts with the value in that field is shown.
Initial thought would be to assign the Custom Field value to a (hidden) tag, but not sure if that’s the best option or where to start, if so.
Any help or advice greatly appreciated.
This will not be easy to achieve in WordPress. What you’re talking about doing is created custom search to search a custom field, but instead of a form to have urls for each custom field value. While not impossible to do on your own, you’d be better off finding an existing search plugin that will let you do it.
If you want to be able to do this on your own I’d suggest using a custom taxonomy rather that a custom field. With a custom taxonomy you can create an archive page in WP the includes a standard WP URL to display the archive for each value.
Thanks for getting back to me.
I anticipate quite a few of these, so don’t think it would be feasible to create an archive page for each one…
As you can probably tell, my knowledge of WP is pretty limited! But one thought I had was to see if upon entry, a custom field option could be essentially duplicated and mapped to a Tag?
Am example setup of these would be…
Custom Field = Country Select
…and so on.
I’d want them to be able to click ‘France’ within a post and it retrieve all posts related to that field selection.
If when added to an option within the custom field setup, UK, France, USA etc were added as Tags, this would solve it?
Apologies if I’m missing the point/ limitations…
Yes, you could map a custom field to a tag, you could create an acf/save_post filter outlined here http://www.advancedcustomfields.com/resources/acfsave_post/, get the field value and then add the term to the post using
wp_set_post_terms(). This is essentially what ACF does for a taxonomy field. If I were setting this up I would more than likely use a custom taxonomy called “Country”, this is a perfect example of were it would be a good choice.
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
Helping others is a great way to earn karma, gain badges and help ACF development!
Accordions are a great way to group related information while allowing users to interactively show and hide content. In this video, Damon Cook goes in-depth on how to create an accessible accordion block using ACF PRO’s Repeater field.https://t.co/RXT0g25akN— Advanced Custom Fields (@wp_acf) March 2, 2023
© 2023 Advanced Custom Fields.