我试图筛选出一个柱式冠军,我得到这个开捕致命错误:类stdClass的客体不能转换为字符串线125 ......在WordPress
Catchable fatal error: Object of class stdClass could not be converted to string in line 125
这里是我使用的代码...
add_filter('wpseo_title', 'vehicle_listing_title', 10, 1);
function vehicle_listing_title($title) {
global $post;
if (get_post_type() == 'vehicles'){
$model = get_queried_object('vehicle_model');
$location = get_queried_object('vehicle_location');
$title = $model . "used cars for sale in" . $location .'on'. get_bloginfo('name'); <---- this is line 125
}
return $title;
}
妈的,顾名思义是'get_queried_object'必须返回一个对象,你刚刚用绳子串连,并没有实现'__toString'我想。试着'var_dump($ model,$ location)'看看。 – Chay22