@tjhole-support I’m trying to do the same and was trying your solution, but while I am able to select an Mp4 in this way, after saving changes the field shows up as empty. Wondering how you were able to overcome this?
@acf-support I was afraid that’s going to be the answer. I knew it had to be an AJAX solution and couldn’t find a way after looking into your core JS code, that’s why I asked here in case I was missing something.
I guess they will have to manually go through (or search) attachments to select one belonging to the specific post, I was hoping I can make it easier.
Hi @acf-support and thanks for your help so far.
I didn’t think about using pre_get_posts so that’s an interesting approach, however the problem is the relationship field is inside of a repeater (so there’s more than one) and I want to be able to do this for _acfuploader fields in each repeater. So custom_field_name would need to be the relationship field that belongs to the same repeater row as the uploader.
Not sure if that’s possible using a query filter.
I’m also having what seems to be a similar issue.
The setup is the following:
– I have a Flexible Content field called “gallery”.
– On the homepage I call have_rows(“gallery”) to show the gallery associated to the homepage.
– I now want to have a separate div for the mobile version of the site which shows the first gallery field for each project (I’ve setup a custom post type called “work”). I use a custom WP_Query to get the required posts of the homepage. This works as expected, but if I then use have_rows(“gallery”) within the WP_Query this seems to completely break WordPress, the page never actually loads, it’s probably stuck in some sort of redirect.
Here is one error from the PHP log:
[10-Dec-2015 18:11:29 UTC] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /Volumes/Date/Dropbox/htdocs/blid/wp-content/plugins/advanced-custom-fields-pro/api/api-template.php on line 552
(the code line varies from what I’ve seen logged)
Does this help in explaining the problem?
I did more digging and I think I might have made this work in a different way, by adding an Image subfield for each row and thus creating the relationship in the repeater, instead of the other way around.
In the gallery code, I can the use get_field to get all the rows and for every images search for a row which has a linked image ID matching the current one.
I’d still be curious to know if it could also be done the other way around.
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!
© 2020 Advanced Custom Fields. Subscribe