Home Forums General Issues Get content from CPT posts and reorder it


Get content from CPT posts and reorder it

  • Hi

    I have 2 CPT’s Films and People.
    I have prizes attributed to Films directed by People and so I need to get those prizes into People as well.

    Prizes on Films are inserted and ordered by Year, Festivals and finally the Prize Name.

    The Structure is:
    . The Film
    – Prizes as a Repeater field (for many prizes per film)
    — Year as a Text field
    — Festivals as a Repeater field (many festivals and many prizes per year)
    —– Festival as PostObject field (get Festival Names from Festival CPT)
    —– Prizes as Relationship (get Prize Names from Prizes CPT)

    Now on People I relate directed films with a Relationship field that get’s the Films.

    To get the Prizes into People I need to get the prizes for all related films and order by year, film, festival and prizes.

    So can I do that?

    Thank you.

  • I can only give you a rough outline of what needs to be done. This would take a good deal of coding.

    When showing a person:

    1. Get all the related films
    2. Loop over the related films and get the data from each film
    3. Build array(s) of data that can be used with either php usort() or php array_multisort() – I would use usort()
    4. Sort the array(s) using either usort() or array_muultisort()
    5. Loop over the sorted array to output the data

    Like I said, I would build a function that works with usort().

    ACF has a basic example of using array_multisort() here

  • Thank you John.
    Noticed on your profile you could code.
    How would it be possible?

  • This reply has been marked as private.
  • John Huebner

    I mean could you present a quotation for that job?

  • Sorry for the late reply. I am not currently taking on any freelance projects. This would not be the correct place to look for someone to take on your dev work.

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

You must be logged in to reply to this topic.