因此,在保存更改后,我尝试用相同帖子的自定义字段权限替换原始的post_title。但是,我在文章页上看到了以下错误:
$PATH/public_html/wp-content/themes/$THEME/functions.php中的警告:在第113行中缺少wpse33385_filter_title()参数2
// replaces the original post_title with the value of pac-short-title
add_filter( 'the_title', 'wpse33385_filter_title', 10, 2);
function wpse33385_filter_title( $title, $post_id )
{
if( $new_title = types_get_field_meta_value( 'pac-short-title', $post_id ) )
{
return $new_title;
}
return $title;
}我很困惑,因为我在add_filter中定义了一些参数?
发布于 2016-06-12 23:43:18
此警告可能是由于在某些版本的WordPress中使用此筛选器的某些实例中未设置post id所致。
解决方案是为post id设置一个默认值。
function wpse33385_filter_title( $title, $post_id = null )https://stackoverflow.com/questions/37779680
复制相似问题