So I'm trying to achieve the following.
My code so far..
add_filter('wpseo_title', 'vehicle_listing_title');
function vehicle_listing_title( $title )
{
if ( get_post_type() == 'vehicles' )
{
$location = get_the_terms($post->ID, 'vehicle_location');
$model = get_the_terms($post->ID, 'vehicle_model');
$title = $model . 'used cars for sale in' . $location .'on'. get_bloginfo('name');
}
return $title;
}
This code results in
$location
&$model
being an object containing the followingterm_id =>,name=>,slug=>,term_group=>,etc
so I want to get thename
part of it.
How do I do that?What do I have to add to the code to still return the modified
$title
even when there aren't any posts assigned to the queried taxonomies?