Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress ACF动态选择值不显示数据_Wordpress_Select_Advanced Custom Fields - Fatal编程技术网

Wordpress ACF动态选择值不显示数据

Wordpress ACF动态选择值不显示数据,wordpress,select,advanced-custom-fields,Wordpress,Select,Advanced Custom Fields,这个问题让我疯狂了将近两周。我知道我不是Wordpress方面的专家,所以我在这里寻求帮助 我已经创建了一个href,当用户单击它时,它将转到新页面 <a href="./create-class?post=<?php echo $post->ID; ?>">Add Class2</a> 我在创建新帖子的创建类页面中有acf表单。在此表单中,有动态选择字段,但选择字段不显示任何数据 <?php acf_form(array(

这个问题让我疯狂了将近两周。我知道我不是Wordpress方面的专家,所以我在这里寻求帮助

我已经创建了一个href,当用户单击它时,它将转到新页面

<a href="./create-class?post=<?php echo $post->ID; ?>">Add Class2</a>
我在创建新帖子的创建类页面中有acf表单。在此表单中,有动态选择字段,但选择字段不显示任何数据

 <?php      acf_form(array(
          'post_id'   => 'new_post',
          'field_groups' => array(150),
          'post_title'  => false,
          'post_content'  => false,
          'new_post'    => array(
                  'post_type'   => 'classes',
                  'post_status' => 'publish',
                  ),
          'return'    => '%post_url%',
          'submit_value'  => 'Submit',
          //'updated_message'    => 'Course Submit!',
        )); ?>

我的代码有问题吗?

我认为这在您的创建类模板中不起作用:

$post = $_GET['post'];
您需要在functions.php文件中设置如下内容:

function custom_query_vars_filter($vars) {
  $vars[] .= 'post';
  return $vars;
}
add_filter( 'query_vars', 'custom_query_vars_filter' );
然后,在创建类模板中,您可以从URL获取变量,如下所示:

$post = get_query_var('post');

看看这是否能让你走上正确的方向。

谢谢你回答我的问题。您的解决方案会给出相同的结果:(@user3239674您能
回送
$post
变量并让我们知道它是否是URL中传递的同一个变量吗?它显示post id 289,但select字段不显示任何内容。我有没有办法将
acf_表单
放入post id循环中?对不起,我真的不擅长编码
function custom_query_vars_filter($vars) {
  $vars[] .= 'post';
  return $vars;
}
add_filter( 'query_vars', 'custom_query_vars_filter' );
$post = get_query_var('post');