前言
使用此筛选器可在 Bricks 模板设置面板中将可用的日期格式设置为所选格式。
用法
将代码加入子主题的 functions.php:
add_filter( 'bricks/dynamic_data/author_value', function( $value, $field_type, $filters ) {
// Example: Append text to author bio
if ( $field_type === 'bio' ) {
return $value . ' [Verified Author]';
}
return $value;
}, 10, 3 );
参数
$value(string):author 字段的值。$field_type(string):正在被检索的特定 author 字段(例如 name、email、bio、website、avatar)。$filters(array):应用于标签的修饰符数组(例如 [‘fallback’ => ‘…’])。
示例代码
筛选返回值
add_filter( 'bricks/dynamic_data/author_value', function( $value, $field_type, $filters ) {
// Example: Append text to author bio
if ( $field_type === 'bio' ) {
return $value . ' [Verified Author]';
}
return $value;
}, 10, 3 );
根据条件短路返回原值
根据条件跳过或修改返回值:
add_filter( 'bricks/dynamic_data/author_value', function( $value, $value ) {
if ( is_admin() ) { return $value; }
// TODO: custom logic here
return $value;
} );
补充说明
更多细节可参考 官方文档。