$tax = 'pa_заданный_вами_слаг_атрибута'
$pa_args = get_terms( $tax, array(
'hide_empty' => false,
)
);
$pa_args = array();
$attribute_taxonomies = wc_get_attribute_taxonomies();
if ( 0 !== count( $attribute_taxonomies ) ) {
foreach ( $attribute_taxonomies as $one_tax ) {
$pa_args[] = get_terms( $one_tax, array(
'hide_empty' => false,
) );
}
}
$test_query_args = array(
'post_type' => 'question',
'posts_per_page' => 4,
);
$end_variable = array();
$test_json_query = get_posts( $test_query_args );
foreach ( $test_json_query as $post ) :
setup_postdata( $post );
$end_variable[] = get_the_title();
endforeach;
wp_reset_postdata();
return rest_ensure_response( $end_variable );