我将从wp\\u查询结果中获取几个字段。我知道wp\\u list\\u pulk()函数,但它只接受一个字段参数。如果我想从找到的每个帖子中获取几个参数,如何获取几个参数?
[
Object1 (ID, name, tag),
Object2 (ID, name, tag),
Object3 (ID, name, tag),
etc.
]
感谢您事后的帮助!
我的代码摘录如下:
$search_param = get_param(\'search_param\', null, \'text\'); // POST param
$term_id = get_term_by(\'name\', "$search_param", \'image_color\')->term_id;
$args = array(
\'post_type\' => \'any\',
\'post_status\' => \'any\',
\'meta_query\' => array(
array(
\'key\' => \'image_color\',
\'value\' => sprintf( \'s:%s:"%s"\', strlen($term_id), $term_id ),
\'compare\' => \'LIKE\'
),
),
);
$query = new WP_Query( $args );
$hello = [
\'ID\' => wp_list_pluck($query->get_posts(), \'ID\'),
\'post_title\' => wp_list_pluck($query->get_posts(), \'post_title\')
];