Support

Account

Home Forums Front-end Issues Linking Custom Fields – Tag or Archive Layout

Solving

Linking Custom Fields – Tag or Archive Layout

  • Hi there,

    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.

    Thanks

  • 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.

    quick search
    https://www.google.com/search?q=wordpress+search+custom+fields&ie=utf-8&oe=utf-8

    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.

  • Hi John,

    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

    1. UK
    2. USA
    3. France

    …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…

    Thanks again.

  • 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.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Linking Custom Fields – Tag or Archive Layout’ is closed to new replies.