But that seems to be for a single image field. How can I get that script to work for a repeating image field? Perhaps make the first image of that field the Featured Image of the post?
Hello. Thank you for contacting the Toolset support.
I would like to know first at what action you want to set the featured image based on repeating field's first instance, is it while using the Toolset form or from backend admin?
Hello Minesh,
I would like this to happen when new pages are created and Saved. If I can run it once for pages that are already created, that would be great.
You mean page or post belongs to custom post type?
There is no automatic feature to add feature image for existing posts but you will require to update post or it will require the custom script that will set the feature image for existing posts/page.
If you can share details and admin access and tell me for what post type you want to set feature image based on repeating field I will review it and guide you the possible solutoin.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Thank you for sharing access details but when I try to login I can only access the profile page. Could you please grand full admin rights to the user you shared and get in touch with me once you do that.
Hello Minesh,
That worked great and I got it to work once on the production site as well. But, I resaved the post type and now the script is not working. It only worked once. Then I saved all the posts to create the featured image, but it stopped working.
Can you tell me what some of those numbers mean, like here: // if a specific form
if ($form_data['id']==77118)
Do I need to update that number for the production environment?
Hello Minesh,
Thank you for looking into this. That's one of the posts where the script worked, but there are several hundred where it's not working. If you look on further pages, there are several hundred where it does not work. Here are some examples: hidden link hidden link hidden link
The issue was with previous code snippet we were using attachment_url_to_postid() function to get the ID based on the image URL but few image URLs having special characters and that is why the function attachment_url_to_postid() failed.
So, I've adjusted the code and we fire a query to get the image ID based on URL and it works as expected. 🙂