Byline
Post author and post info
Block name
t2/byline
Filters
Template
The full template returned by the render callback function can be overwritten using the t2/block/byline/template filter.
Date/Time Output
The t2/block/byline/get_time_or_date filter allows you to customize the date output for posted and updated dates. This provides extensive control over how dates are formatted and displayed based on project requirements.
Parameters:
$output(string) - The computed date markup$post_id(int|null) - The post ID$timestamp(int) - The timestamp (generic date)$format(string) - The output format$field(string) - The date field ('date' or 'modified')$date(\DateTimeImmutable) - The date object$date_format(string) - The date format from WordPress settings$time_format(string) - The time format from WordPress settings$time_string(string) - The time string markup template$days_since_post(int) - Number of days since the date
Usage
\add_filter('t2/block/byline/get_time_or_date', function($output, $post_id, $timestamp, $format, $field, $date, $date_format, $time_format, $time_string, $days_since_post) {
// Customize date output based on project requirements
if ($field === 'modified' && $days_since_post > 30) {
return sprintf($time_string, $date->format('c'), 'Updated ' . $date->format($date_format));
}
return $output;
}, 10, 10);
Author
The filter t2/block/byline/author has been added to replace the author name, for instance if using Co Authors Plus.
Author role
The block has a custom filter t2/block/byline/author_role to override the author role value, if you want to dynamically get this value from user meta or another source.
Usage
\add_filter('t2/block/byline/author_role', function($role) {
if (!empty($role)) {
return $role;
}
return 'My Custom Role';
});
Author avatar
By default, when avatar display is enabled it gets the default profile avatar. You can override this with the t2/block/byline/author_avatar filter.
Usage
\add_filter('t2/block/byline/author_role', function() {
return '<img src="" alt="" />';
});
Style properties
Small text color
- --t2-byline-color-small-text
- Theme.json: wp.custom.t2-byline.color.small-text
- Default: #767676
Avatar border radius
- --t2-byline-avatar-radius
- Theme.json: wp.custom.t2-byline.color.avatarRadius
- Default: 50%
Avatar size
- --t2-byline-avatar-size
- Theme.json: wp.custom.t2-byline.avatarSize
- Default: clamp(3rem,
Spacing
- --t2-byline-spacing
- Theme.json: wp.custom.t2-byline.color.small-text
- Default: 50%