【发布时间】:2016-06-12 22:26:05
【问题描述】:
所以我试图在保存更改后将原始 post_title 替换为同一帖子的自定义字段。但是,我在帖子页面上收到以下错误:
警告:第 113 行 $PATH/public_html/wp-content/themes/$THEME/functions.php 中 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 中定义了许多参数?
【问题讨论】:
-
您的相关
apply_filters()电话在哪里? -
@Tristan 你是什么意思?该功能有效,但在前端显示警告。