我试图从RivetsJs Binder创建一个PHP $ tourId变量。 RivetsJs Binder正在从WordPress REST API中提取Id。我希望从中获取ID 1726,当我回显变量时,我得到数字1726,但当我尝试将它与get_field一起使用时,它不起作用。
$tourId = '{app.selectedTour.id}';
echo $tourId;
$table = get_field( 'time_availability_table_one', $tourId );
但是当我将ID 1726作为String或Integer放入$ tourId变量时:
$tourId = '1726';
echo $tourId;
$table = get_field( 'time_availability_table_one', $tourId );
然后它完美无缺。
在这里发布这个问题之前试图找到我的问题的解决方案时,我读到,因为PHP是服务器端而JS是客户端,这不应该工作,但这并不能解释我是怎么做的设法回应正确的ID。
我首先创建了什么样的变量,如何修复它以便与get_field一起使用?