- This topic has 7 replies, 2 voices, and was last updated 1 month, 1 week ago by .
I need a way to add a unique ID to each group of fields so I can find that particular group even if the other values in the group are changed. To explain:
I need to create a settings page where the admin user can create a list of video-urls and titles to be used in a dropdown on a page meta box so the page creator can just select a pre-approved video to insert into the page. OK so just create settings page, add a cloneable group of fields for video name and video url. In the Page metabox generate a select dropdown by getting the list of video names from settings, saving the video name as a Page meta, then when displaying the page, look up the videoname from the page meta, use that to find the matching video url in the settings, display video.
OK so far so good. But there is a clear flaw – what if the name of the video is changed by the admin/ The page video name meta is out of date, and it can longer find the video-url. Saving the Videoname and the video URL with the page meta partially solves this but means the admin cannot change the video name, or even update the video url across the site.
Ok another answer is to use a CPT to store video names and urls. The page meta then just stores the video CPT post id and looks that up on each page display. Works but is not as easy to use or as graceful as a settings page with a list of sortable clonable entries.
So really what I want is a unique ID to store with each field group. This has to be generated for each new group the admin user creates and then is stored as an extra field with the group fields. This field value id is then used as the ‘value’ option in the select for the page meta, and can always be used to find the correct video name and url. Is this in any way possible?
Thanks in advance for any replies.
- You must be logged in to reply to this topic.