Tell us what you are trying to do?
Getting image ids of repeatable fields via PHP in Oxygen Builder via the code proposed
but it doesn't produce an output via do_shortcode. I created the shortcode with a custom plugin.
here is my code trying to get the output:
$para = do_shortcode("[get_image_id id='" . get_the_ID() . "' field='wpcf-bilder']");
thank you very much for your help - unfortunately this code doesn't work either.
Don't know why.
I am trying to build it into a template that is built with Oxygen Builder.
It looks like it doesn't find the repeatable group as the array seems to be empty when I echo it.
The slug in Toolset is "bilder" but it doesn't work wether I use "wpcf-bilder" nor just "bilder".
In a case like this we need to know if the correct data is being passed along.
Can you do a var_dump on the $post_id variable as well as the $image_urls variable.
This is to check to see if the data that we are expecting is actually being passed. For the $post_id ID variable can you confirm that the ID that is dumped out on the page is the correct ID of the current post being viewed.
$post = get_post( get_the_ID() ); // the parent post that holds the RFG
$rfgs = toolset_get_related_posts(
$post, // the parent post
'bilder', // the RFG slug
'parent', // the post role in this relationship is 'parent'
10000, // the maximum number of results
0, // the offset
array(), // additional query arguments
'post_id', // return format
'child', // role to return
);
The code above is for Post Relationships. This is meant to be used when there is a relationship created between two post types.
What I need clarity on here is if this is a repeatable field or is it a repeatable field group because the code will be changed based on that assumption.
If it is a repeatable field group then this will complicate things because we will first need to loop through each of the fields in the repeatable field group and then collect the IDs of the images in each of them and store it in an array. So before we go any further I will need to know if it a Repeatable field Group or Repeatable Fields.
Perhaps you can send me a screenshot of the fields on the backend as well.
it is a Repeatable field group.
Is it possible to convert that into repeatable fields somehow?
If not, then yes, the code is more complex.
Here is login data:
andreas.convernatics.com/wp-admin
user: toolset_shane
password: sgvt&ZW1Ejns4GsEDyxDq2cy
Adress of the oxygen template: hidden link
the code is in the code block in the middle section if you want to try something, feel free, it is a development site.
Unfortunately this doesn't work and I think it is because of all the ' and " in there. This turns out to be a very tricky thing to do, while I thought it would be fairly easy.
I may have spotted the issue, you perhaps don't need the single inverted commas to concatenate the variable with the string. Given that the double quotes would already allow it to convert to string values.