Home Forums General Issues dynamically list all selected radio button values


dynamically list all selected radio button values

  • I’m using ACF along with Isotope to filter a list of items (posts). The filtering options are set via an ACF radio button on each post. What I can’t figure out is how to dynamically get a list of ONLY the radio options that have been selected (across all posts), which I would then use to create the filtering buttons. Why is this needed? As of right now there are only a handful of posts (items to be filtered), but 20+ radio button options (filtering choices). I don’t want half the filtering buttons to return no results on the front end, I only want filtering buttons to show that have a post attached to them.

    So if there are 3 posts with the following selections –
    Post 1: Filtering Option 3
    Post 2: Filtering Option 7
    Post 3: Filtering Option 2

    The front end should list out the buttons as follows –
    [Filtering Option 2] [Filtering Option 3] [Filtering Option 7]
    Post 1
    Post 2
    Post 3

    NOT like this –
    [Filtering Option 1] [Filtering Option 2] [Filtering Option 3] [Filtering Option 4] [Filtering Option 5] [Filtering Option 6] [Filtering Option 7] [Filtering Option 8] [Filtering Option 9] [etc etc etc]
    Post 1
    Post 2
    Post 3

    I can manage turning the output into functioning buttons, but any help on how to actually produce this loop of selected-radio-button-values would be greatly appreciated!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.