Okay, bear with as I'm not very good at php! I have this in a Wordpress template which is basically getting the categories that are attached to a post and displaying them.
<?php
$categories = wp_get_post_categories( $post->ID, array('fields' => 'ids'));
if($categories) {
$cat_ids = implode(',' , $categories);
$cats = wp_list_categories('title_li=Listed in:&style=none&echo=0&include='.$cat_ids);
echo str_replace('<br />', ' > ', $cats);
}
?>
This displays the following:
Food > Fruit > Apple >
But I need to remove the last separating character. In this case the ">" so it reads
Food > Fruit > Apple
I've seen a lot of different things such as rtrim etc but I just don't know how to get them to work with the current code I have.
Any help would be really appreciated.