astra_post_author_name()

Function to get Author name.


Description


Return

(mixed) $author_name Author name.


Source

File: inc/blog/blog-config.php

function astra_post_author_name() {
	$author_name = '';
	if ( empty( get_the_author() ) ) {
		/** @psalm-suppress InvalidGlobal */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
		global $post;
		/** @psalm-suppress InvalidGlobal */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
		if ( is_object( $post ) && isset( $post->post_author ) ) {
			$user_id = $post->post_author;
			/** @psalm-suppress InvalidGlobal */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
			global $authordata;
				/** @psalm-suppress InvalidGlobal */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
			$author_data = '';
			if ( ! $authordata ) {
				$author_data = get_userdata( $user_id );
			}

			$author_name = esc_attr( ! empty( $author_data ) ? $author_data->display_name : '' );
		}
	} else {
		$author_name = get_the_author();
	}

	return $author_name;
}

Changelog

Changelog
Version Description
4.0.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.