# Block Bindings Source: Author Details

> Registers a block bindings source so paragraphs, headings, buttons and images can show the post author's name, bio, archive link or avatar, which is handy for author boxes in block themes.

- Type: PHP
- Runs: Run everywhere
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: block-bindings, authors, block-themes
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/bindings-author-details/

## Code

```php
add_action( 'init', function () {
    if ( ! function_exists( 'register_block_bindings_source' ) ) {
        return;
    }

    register_block_bindings_source( 'wpide/author', array(
        'label'              => 'Post author',
        'uses_context'       => array( 'postId' ),
        'get_value_callback' => function ( $args, $block ) {
            $post_id   = ! empty( $block->context['postId'] ) ? (int) $block->context['postId'] : get_the_ID();
            $author_id = (int) get_post_field( 'post_author', $post_id );
            if ( ! $author_id ) {
                return null;
            }

            switch ( $args['key'] ?? 'name' ) {
                case 'bio':
                    return esc_html( get_the_author_meta( 'description', $author_id ) );
                case 'url':
                    return esc_url( get_author_posts_url( $author_id ) );
                case 'avatar':
                    return esc_url( get_avatar_url( $author_id, array( 'size' => 256 ) ) );
                case 'website':
                    return esc_url( get_the_author_meta( 'user_url', $author_id ) );
                default:
                    return esc_html( get_the_author_meta( 'display_name', $author_id ) );
            }
        },
    ) );
} );
```

## Notes

Needs WordPress 6.5+; bind with "source":"wpide/author" and args {"key":"name"} (also bio, url, avatar) in the block's metadata.bindings.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Block Bindings Source: Author Details" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
