get_the_author_meta example


function render_block_core_post_author_biography( $attributes$content$block ) {
    if ( ! isset( $block->context['postId'] ) ) {
        return '';
    }

    $author_id = get_post_field( 'post_author', $block->context['postId'] );
    if ( empty( $author_id ) ) {
        return '';
    }

    $author_biography = get_the_author_meta( 'description', $author_id );
    if ( empty( $author_biography ) ) {
        return '';
    }

    $align_class_name   = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
    $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );

    return sprintf( '<div %1$s>', $wrapper_attributes ) . $author_biography . '</div>';
}

/** * Registers the `core/post-author-biography` block on the server. */


if ( ! function_exists( 'twenty_twenty_one_posted_by' ) ) {
    /** * Prints HTML with meta information about theme author. * * @since Twenty Twenty-One 1.0 * * @return void */
    function twenty_twenty_one_posted_by() {
        if ( ! get_the_author_meta( 'description' ) && post_type_supports( get_post_type(), 'author' ) ) {
            echo '<span class="byline">';
            printf(
                /* translators: %s: Author name. */
                esc_html__( 'By %s', 'twentytwentyone' ),
                '<a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" rel="author">' . esc_html( get_the_author() ) . '</a>'
            );
            echo '</span>';
        }
    }
}


function the_author_meta( $field = '', $user_id = false ) {
    $author_meta = get_the_author_meta( $field$user_id );

    /** * Filters the value of the requested user metadata. * * The filter name is dynamic and depends on the $field parameter of the function. * * @since 2.8.0 * * @param string $author_meta The value of the metadata. * @param int|false $user_id The user ID. */
    
if ( empty( $author_id ) ) {
        return '';
    }

    $avatar = ! empty( $attributes['avatarSize'] ) ? get_avatar(
        $author_id,
        $attributes['avatarSize']
    ) : null;

    $link        = get_author_posts_url( $author_id );
    $author_name = get_the_author_meta( 'display_name', $author_id );
    if ( ! empty( $attributes['isLink'] && ! empty( $attributes['linkTarget'] ) ) ) {
        $author_name = sprintf( '<a href="%1$s" target="%2$s">%3$s</a>', esc_url( $link )esc_attr( $attributes['linkTarget'] )$author_name );
    }

    $byline  = ! empty( $attributes['byline'] ) ? $attributes['byline'] : false;
    $classes = array();
    if ( isset( $attributes['itemsJustification'] ) ) {
        $classes[] = 'items-justified-' . $attributes['itemsJustification'];
    }
    if ( isset( $attributes['textAlign'] ) ) {
        $classes[] = 'has-text-align-' . $attributes['textAlign'];
    }
<?php /** * The template for displaying author info below posts. * * @package WordPress * @subpackage Twenty_Twenty_One * @since Twenty Twenty-One 1.0 */

?> <?php if ( (bool) get_the_author_meta( 'description' ) && post_type_supports( get_post_type(), 'author' ) ) : ?> <div class="author-bio <?php echo get_option( 'show_avatars' ) ? 'show-avatars' : ''; ?>"> <?php echo get_avatar( get_the_author_meta( 'ID' ), '85' ); ?> <div class="author-bio-content"> <h2 class="author-title"> <?php             printf(
                /* translators: %s: Author name. */
                esc_html__( 'By %s', 'twentytwentyone' ),
                get_the_author()
            );
            ?>
admin_url( 'revision.php' )
                    ),
                    "restore-post_{$revision->ID}"
                )
            );
        }

        if ( ! isset( $authors[ $revision->post_author ] ) ) {
            $authors[ $revision->post_author ] = array(
                'id'     => (int) $revision->post_author,
                'avatar' => $show_avatars ? get_avatar( $revision->post_author, 32 ) : '',
                'name'   => get_the_author_meta( 'display_name', $revision->post_author ),
            );
        }

        $autosave = (bool) wp_is_post_autosave( $revision );
        $current  = ! $autosave && $revision->post_modified_gmt === $post->post_modified_gmt;
        if ( $current && ! empty( $current_id ) ) {
            // If multiple revisions have the same post_modified_gmt, highest ID is current.             if ( $current_id < $revision->ID ) {
                $revisions[ $current_id ]['current'] = false;
                $current_id                          = $revision->ID;
            } else {
                
 'wp-block-avatar__image';

    // Unlike class, `get_avatar` doesn't filter the styles via `esc_attr`.     // The style engine does pass the border styles through     // `safecss_filter_attr` however.     $image_styles = ! empty( $border_attributes['style'] )
        ? sprintf( ' style="%s"', esc_attr( $border_attributes['style'] ) )
        : '';

    if ( ! isset( $block->context['commentId'] ) ) {
        $author_id   = isset( $attributes['userId'] ) ? $attributes['userId'] : get_post_field( 'post_author', $block->context['postId'] );
        $author_name = get_the_author_meta( 'display_name', $author_id );
        // translators: %s is the Author name.         $alt          = sprintf( __( '%s Avatar' )$author_name );
        $avatar_block = get_avatar(
            $author_id,
            $size,
            '',
            $alt,
            array(
                'extra_attr' => $image_styles,
                'class'      => $image_classes,
            )
        );

function get_the_archive_description() {
    if ( is_author() ) {
        $description = get_the_author_meta( 'description' );
    } elseif ( is_post_type_archive() ) {
        $description = get_the_post_type_description();
    } else {
        $description = term_description();
    }

    /** * Filters the archive description. * * @since 4.1.0 * * @param string $description Archive description to be displayed. */

function render_block_core_post_author_name( $attributes$content$block ) {
    if ( ! isset( $block->context['postId'] ) ) {
        return '';
    }

    $author_id = get_post_field( 'post_author', $block->context['postId'] );
    if ( empty( $author_id ) ) {
        return '';
    }

    $author_name = get_the_author_meta( 'display_name', $author_id );
    if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
        $author_name = sprintf( '<a href="%1$s" target="%2$s" class="wp-block-post-author-name__link">%3$s</a>', get_author_posts_url( $author_id )esc_attr( $attributes['linkTarget'] )$author_name );
    }

    $classes = array();
    if ( isset( $attributes['textAlign'] ) ) {
        $classes[] = 'has-text-align-' . $attributes['textAlign'];
    }
    if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
        $classes[] = 'has-link-color';
    }
    
/** * Retrieve the description of the author of the current post. * * @since 1.5.0 * @deprecated 2.8.0 Use get_the_author_meta() * @see get_the_author_meta() * * @return string The author's description. */
function get_the_author_description() {
    _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'description\')' );
    return get_the_author_meta('description');
}

/** * Display the description of the author of the current post. * * @since 1.0.0 * @deprecated 2.8.0 Use the_author_meta() * @see the_author_meta() */
function the_author_description() {
    _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'description\')' );
    

                $excerpt = wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );

                $is_sticky = is_sticky( $post->ID ) ? 1 : 0;
                ?> <item> <title><?php echo $title; ?></title> <link><?php the_permalink_rss(); ?></link> <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate> <dc:creator><?php echo wxr_cdata( get_the_author_meta( 'login' ) ); ?></dc:creator> <guid isPermaLink="false"><?php the_guid(); ?></guid> <description></description> <content:encoded><?php echo $content; ?></content:encoded> <excerpt:encoded><?php echo $excerpt; ?></excerpt:encoded> <wp:post_id><?php echo (int) $post->ID; ?></wp:post_id> <wp:post_date><?php echo wxr_cdata( $post->post_date ); ?></wp:post_date> <wp:post_date_gmt><?php echo wxr_cdata( $post->post_date_gmt ); ?></wp:post_date_gmt> <wp:post_modified><?php echo wxr_cdata( $post->post_modified ); ?></wp:post_modified> <wp:post_modified_gmt><?php echo wxr_cdata( $post->post_modified_gmt ); ?></wp:post_modified_gmt> <wp:comment_status><?php echo wxr_cdata( $post->comment_status ); ?></wp:comment_status> <wp:ping_status><?php echo wxr_cdata( $post->ping_status ); ?></wp:ping_status> <wp:post_name>

    do_action( 'atom_head' );

    while ( have_posts() ) :
        the_post();
        ?> <entry> <author> <name><?php the_author(); ?></name> <?php             $author_url = get_the_author_meta( 'url' );
            if ( ! empty( $author_url ) ) :
                ?> <uri><?php the_author_meta( 'url' ); ?></uri> <?php             endif;

            /** * Fires at the end of each Atom feed author entry. * * @since 3.2.0 */
            
$featured_image
            );
        }

        $list_items_markup .= sprintf(
            '<a class="wp-block-latest-posts__post-title" href="%1$s">%2$s</a>',
            esc_url( $post_link ),
            $title
        );

        if ( isset( $attributes['displayAuthor'] ) && $attributes['displayAuthor'] ) {
            $author_display_name = get_the_author_meta( 'display_name', $post->post_author );

            /* translators: byline. %s: current author. */
            $byline = sprintf( __( 'by %s' )$author_display_name );

            if ( ! empty( $author_display_name ) ) {
                $list_items_markup .= sprintf(
                    '<div class="wp-block-latest-posts__post-author">%1$s</div>',
                    $byline
                );
            }
        }

        
function wp_post_revision_title_expanded( $revision$link = true ) {
    $revision = get_post( $revision );

    if ( ! $revision ) {
        return $revision;
    }

    if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) {
        return false;
    }

    $author = get_the_author_meta( 'display_name', $revision->post_author );
    /* translators: Revision date format, see https://www.php.net/manual/datetime.format.php */
    $datef = _x( 'F j, Y @ H:i:s', 'revision date format' );

    $gravatar = get_avatar( $revision->post_author, 24 );

    $date      = date_i18n( $datefstrtotime( $revision->post_modified ) );
    $edit_link = get_edit_post_link( $revision->ID );
    if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) {
        $date = "<a href='$edit_link'>$date</a>";
    }

    
/** * Handles the post author column output. * * @since 4.3.0 * * @param WP_Post $post The current WP_Post object. */
    public function column_author( $post ) {
        $args = array(
            'post_type' => $post->post_type,
            'author'    => get_the_author_meta( 'ID' ),
        );
        echo $this->get_edit_link( $argsget_the_author() );
    }

    /** * Handles the default column output. * * @since 4.3.0 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. * * @param WP_Post $item The current WP_Post object. * @param string $column_name The current column name. */
Home | Imprint | This part of the site doesn't use cookies.