Post data block

The Post data block can render various data about the current post.

ska/post-data is an alternative to WordPress core blocks such as Title, Excerpt and Categories. The block aims to produce cleaner markup than the aforementioned as well as support more customization options, such as using a different tag name and adding custom HTML attributes.

The Post data appearance controls allow to truncate the value to a certain max length.

When in Terms mode, the max length determines how many terms (Categories, Tags) are displayed.

The following filter can be used to modify the output of this block:

Filters

When using the Post data block with type Meta you can alter the meta value that it has fetched with the following filter (this works when the meta had a truthy value):

Modify the value of post data block Meta valuePHP
/**
 * @param mixed $meta_value Truthy and scalar meta value.
 * @param string $meta_key Meta key that the value is from.
 * @return string Value to render.
 */
add_filter('ska_blocks_render_post_meta', function($meta_value, $meta_key) {
	return $meta_value;
}, 10, 2);

Alternatively, you can provide a value to early and not hit the get_post_meta call at all, which allows to use this block to provide any sort of output, not actual post meta:

Sideload the value of Post data block Meta valuePHP
/**
 * @param string $meta_value Empty string.
 * @param string $meta_key Meta key that the value is from.
 * @return string Value to render instead of retrieving post meta.
 */
add_filter('ska_blocks_pre_render_post_meta', function($meta_value, $meta_key) {
	return $meta_value;
}, 10, 2);

The final value that is rendered in any case can be modified with the following filter:

Modify the final value of Post data blockPHP
/**
 * @param array $attributes Block attributes.
 * @param WP_Block $block Block instance.
 * @return string
 */
add_filter('ska_blocks_render_post_data', function($output, $attributes, $block) {
	return $output;
}, 10, 3);