$args = array('post_type' => 'custom_post_type', 'tax_query' => array( array( 'taxonomy' => 'custom_taxonomy', 'field' => 'slug', 'terms' => $custom_term->slug, ), ), ); $loop = new WP_Query($args); if($loop->have_posts()) { while($loop->have_posts()) : $loop->the_post(); echo get_the_title(); endwhile; }
How to group an array of associative arrays by key in PHP
$result = array();
foreach ($data as $element) {
$result[$element['id']][] = $element;
}
How To Get All The Terms In A Given Taxonomy Or List Of Taxonomies
$args = get_terms(
array(
‘taxonomy’ => ‘group-study’,
‘hide_empty’ => false,
)
);
$query = newWP_Query( $args );
https://developer.wordpress.org/reference/functions/get_terms/
How To Convert Object To An Array in PHP
1. Typecasting Object to Array PHP
$array = (array) $object;
2. Using the JSON Decode and Encode Method
json_decode(json_encode($object), true);