Hi there,
The built-in functions of the dynamic data can not pull the user data, if you set the ACF field return value to ID, the headline block will be able to output the ID of the user by setting the dynamic data source to post meta > your field name
, but I don’t think it’s able to output the name or adding user archive to it.
It will require custom coding to alter the output, try follow below steps:
- add a CSS class to the headline block, eg.
post-translator
. https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/
- add this PHP code, replace
translator
with the actual acf field name.
add_filter('generateblocks_dynamic_content_output', function($content, $attributes, $block){
if ( ! is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'post-translator' ) !== false ) {
$post_id = get_the_ID();
$translator_id = get_field('translator', $post_id);
if ($translator_id) {
// Retrieve the user's name
$translator_name = get_the_author_meta('display_name', $translator_id);
$content = esc_html($translator_name);
}
return $content;
}
}, 10, 3);
add_filter('generateblocks_dynamic_url_output', function($url, $attributes) {
if ( ! is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'post-translator' ) !== false ) {
$post_id = get_the_ID();
$translator_id = get_field('translator', $post_id);
if ($translator_id) {
// Retrieve the user's archive URL
$translator_archive_url = get_author_posts_url($translator_id);
$url = esc_url( $translator_archive_url);
}
return $url;
}
}, 10, 2);