For example, use the admin_footer action (and use get_current_screen() to check that you’re on the right screen), to emit a script tag that hooks into the html emitted by the repeater support code.
You would have to figure out how you want to identify the copy from and copy to locations (if you made it always be the last two items, that would simplify your work for your initial draft).
Anyways, not a completely trivial task (but much easier if you limit yourself to just the fields you’re actually using than if you try and build a general structure that anticipates future acf changes).
If you go this route, you’ll also need to leave some notes on how to test a new acf update to make sure your mechanism still works with it.
Manually copying the contents might be a bit more work than using an automated mechanism, but unless this gets used a lot, it might actually wind up being a lot less work in the larger scheme of things.
Or wait wait wait… did you mean “tag” like the wordpress taxonomy? Because, if so, that’s a completely different query.
I suppose some cautions are in order:
*) never cache if you can’t measure the difference in performance (you won’t know if you are making things better or worse).
*) writing code for a wordpress theme tends to be different from writing code for a wordpress plugin.
*) if you’re doing this on a “multisite” (or have a strange configuration) that would also change the details of the query.
*) the code snippet I posted was intended to be in the body of a php function.
*) if you need this to be a part of the $wp_query, that introduces other issues (including things like the url structure that this fits into).
Anyways, if this doesn’t work, I would have to ask you for more information about what specifically you’re doing.
(And, if you’re using wordpress ‘tags’ (also known as the ‘term’ taxonomy), then maybe you should be doing some other things different. Like maybe it makes sense to have a video custom post type and have the tags on the videos rather than buried deep in the artist description?)
Personally, I use $wpdb to query repeater fields. This might not be the best way (you might want to use wp_cache_set/wp_cache_get if this turns into a performance issue), but it works for me.
If I understand your situation properly, I imagine something like this (warning, untested code):
global $wpdb; return $wpdb->get_col("SELECT DISTINCT post_id FROM wp_postmeta m INNER JOIN wp_posts p ON m.post_id = p.id AND p.post_type='artist' WHERE m.meta_key LIKE 'video\_%\_tag' AND m.meta_value='featured'");
If I am not mistaken about your setup, this would return a list of artist post ids where any of the tags in your video repeater is set to ‘featured’.
Note that, as written, this would return both published and unpublished posts. If you wanted just published posts you’d need to add that constraint to the query (in the where clause, something like: AND p.post_type=’publish’).
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!