Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.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
Php 获取Wordpress ACF Taxomony并添加到类别_Php_Advanced Custom Fields_Wordpress - Fatal编程技术网

Php 获取Wordpress ACF Taxomony并添加到类别

Php 获取Wordpress ACF Taxomony并添加到类别,php,advanced-custom-fields,wordpress,Php,Advanced Custom Fields,Wordpress,我正在使用ACF获取分类法,如何获取$place(这是选定的分类法)并将其添加到installgallery\u places post查询?我的代码是: 我相信你可以这样做 $args = array( 'post_type'=> 'installgallery', 'meta_query' => array( array( 'key' => 'installga

我正在使用ACF获取分类法,如何获取$place(这是选定的分类法)并将其添加到installgallery\u places post查询?我的代码是:


我相信你可以这样做

 $args = array( 
    'post_type'=> 'installgallery', 
    'meta_query' => array(
                      array(
                        'key' => 'installgallery_places',
                         'value' => $place,
                         )
                    )


  );

如果您删除变量
$place

周围的单引号,它可能会与您的原始代码一起工作。这是一个经过反复试验得出的结果,必须在返回值中将ACF分类法更改为“Term Object”,并使用以下代码返回slug:

<?php
$variable = get_field('choose_place');
$args = array(
'post_type'=> 'installgallery',
'installgallery_places' => $variable->slug
);              
$the_query = new WP_Query( $args );