How can I put RivetsJs Binder to a PHP variable

31 views Asked by At

I'm trying to create a PHP $tourId variable from a RivetsJs Binder. The RivetsJs Binder is pulling the Id from WordPress REST API. I'm hoping to get the ID 1726 from it, and when I echo the variable I get the number 1726, but when I try to use it with get_field it doesn't work.

$tourId = '{app.selectedTour.id}';
echo $tourId;

$table = get_field( 'time_availability_table_one', $tourId );

But when I put the ID 1726 into the $tourId variable as a String or an Integer like this:

$tourId = '1726';
echo $tourId;

$table = get_field( 'time_availability_table_one', $tourId );

Then it works perfectly.

When trying to find a solution to my problem before posting this question here, I read that since PHP is server side and JS is client side this should not work, but that doesn't explain how I'm managing to echo the right ID.

What kind of variable am I creating in the first place and how can I fix it so it works with get_field?

0

There are 0 answers