Support

Account

Home Forums Add-ons Repeater Field Search query in repeater field

Helping

Search query in repeater field

  • Hi everybody, Excuse me for my bad english, I don’t speak good english… :-/

    It’s my first experience with the ACF plugin and repeater field AddOn.

    I have a little question. I have make a new Taxinomy: Radioshows

    In my taxinomy, I have make a repeater field “diffusion” with:

    – Day
    – Start
    – End

    So I have in my post:

    Title: Show 1
    Diffusion:
    Monday, 08:00, 9:00
    Sunnday, 09:00, 12:00

    Title: Show 2
    Diffusion:
    Monday, 09:00, 10:00

    I search to make a query for the on air show. Why can I search the current show for the actual time?

    I have taste most solution but doesn’t work…

    Thank’s for your help 🙂

    Bests,

    Matthieu

    • Elliot

    • November 28, 2013 at 10:01 am

    Hi @matthieu82

    Just to clarify, you are asking how to find the row of data which relates to the current taxonomy and the current time.

    Am I right in assuming that the ‘current taxonomy’ will be found by viewing the taxonomy single page, via it’s permalink?

    This can be done it 2 steps.

    The first is to load the repeater data, which you can do via the have_rows function. Please see the docs here: http://www.advancedcustomfields.com/resources/functions/have_rows/

    Please note that because this is data for a taxonomy term, you will need to specify the post_id like so: http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/

    Once you have a loop working, you shouls attempt to print out each loops day and time data.

    Your next step will be to add some logic WITHIN the loop to determin if the current row matches the current time. You can get the current time in PHP via the time, or date function. Please use google to find docs on how to get the current time in different formats.

    You can then simply compare the sub field values (get_sub_field) with your current day / time variables and allow the loop to render the row, or use ‘continue’ to skip the row.

    Hope that helps.

    Thanks
    E

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.