You code is completely wrong. array_shift
should not be used
array_shift() shifts the first value of the array off and returns it, shortening the array by one element and moving everything down. All numerical array keys will be modified to start counting from zero while literal keys won’t be touched.
You should have a look at the correct use of get_the_terms
in the codex.
I would just like to point out, I usually make use of wp_list_categories
as it gives a lot of flexibility, and it also works with custom taxonomies. Here is a example from the codex
<?php
$taxonomy = 'wpsc_product_category';
// get the term IDs assigned to post.
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// separator between links
$separator=", ";
if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {
$term_ids = implode( ',' , $post_terms );
$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=" . $term_ids );
$terms = rtrim( trim( str_replace( "<br />', $separator, $terms ) ), $separator );
// display post categories
echo $terms;
}
?>