I have the following code within a WP loop
<?php
// Get the selected taxonomies for the post type
$terms = get_the_terms( get_the_ID(), 'course_type' );
$classes = array();
if ( $terms && ! is_wp_error( $terms ) ){
foreach ( $terms as $term) {
$classes[] = $term->slug;
}
}
?>
What I am looking to do is print only the WP_Term object slug to use in the classes.
<div class="courses-search-result standout-box-shadow <?php print_r( $classes ); ?>">
Now, I have got it working to a point and printing a value in the classes - but it is also printing the array structure:
class="courses-search-result standout-box-shadow cilex-clearfix Array
(
[0] => apprenticeship
)
"
Am I close to getting the correct code with my PHP? My knowledge of the language is basic right now so any help would be much appreciated.