get_the_author_link

The timeline below displays how wordpress function get_the_author_link has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Retrieves either author's link or author's name.
 *
 * If the author has a home page set, return an HTML link, otherwise just return
 * the author's name.
 *
 * @since 3.0.0
 *
 * @global WP_User $authordata The current author's data.
 *
 * @return string An HTML link if the author's URL exists in user meta,
 *                otherwise the result of get_the_author().
 */
function get_the_author_link()
{
    if (get_the_author_meta('url')) {
        global $authordata;
        $author_url = get_the_author_meta('url');
        $author_display_name = get_the_author();
        $link = sprintf(
            '<a href="%1$s" title="%2$s" rel="author external">%3$s</a>',
            esc_url($author_url),
            /* translators: %s: Author's display name. */
            esc_attr(sprintf(__('Visit %s&#8217;s website'), $author_display_name)),
            $author_display_name
        );
        /**
         * Filters the author URL link HTML.
         *
         * @since 6.0.0
         *
         * @param string  $link       The default rendered author HTML link.
         * @param string  $author_url Author's URL.
         * @param WP_User $authordata Author user data.
         */
        return apply_filters('the_author_link', $link, $author_url, $authordata);
    } else {
        return get_the_author();
    }
}

WordPress Version: 6.1

/**
 * Retrieves either author's link or author's name.
 *
 * If the author has a home page set, return an HTML link, otherwise just return the
 * author's name.
 *
 * @since 3.0.0
 *
 * @global WP_User $authordata The current author's data.
 *
 * @return string|null An HTML link if the author's url exist in user meta,
 *                     else the result of get_the_author().
 */
function get_the_author_link()
{
    if (get_the_author_meta('url')) {
        global $authordata;
        $author_url = get_the_author_meta('url');
        $author_display_name = get_the_author();
        $link = sprintf(
            '<a href="%1$s" title="%2$s" rel="author external">%3$s</a>',
            esc_url($author_url),
            /* translators: %s: Author's display name. */
            esc_attr(sprintf(__('Visit %s&#8217;s website'), $author_display_name)),
            $author_display_name
        );
        /**
         * Filters the author URL link HTML.
         *
         * @since 6.0.0
         *
         * @param string  $link       The default rendered author HTML link.
         * @param string  $author_url Author's URL.
         * @param WP_User $authordata Author user data.
         */
        return apply_filters('the_author_link', $link, $author_url, $authordata);
    } else {
        return get_the_author();
    }
}

WordPress Version: 5.3

/**
 * Retrieve either author's link or author's name.
 *
 * If the author has a home page set, return an HTML link, otherwise just return the
 * author's name.
 *
 * @since 3.0.0
 *
 * @return string|null An HTML link if the author's url exist in user meta,
 *                     else the result of get_the_author().
 */
function get_the_author_link()
{
    if (get_the_author_meta('url')) {
        return sprintf(
            '<a href="%1$s" title="%2$s" rel="author external">%3$s</a>',
            esc_url(get_the_author_meta('url')),
            /* translators: %s: Author's display name. */
            esc_attr(sprintf(__('Visit %s&#8217;s website'), get_the_author())),
            get_the_author()
        );
    } else {
        return get_the_author();
    }
}

WordPress Version: 4.8

/**
 * Retrieve either author's link or author's name.
 *
 * If the author has a home page set, return an HTML link, otherwise just return the
 * author's name.
 *
 * @since 3.0.0
 *
 * @return string|null An HTML link if the author's url exist in user meta,
 *                     else the result of get_the_author().
 */
function get_the_author_link()
{
    if (get_the_author_meta('url')) {
        return sprintf(
            '<a href="%1$s" title="%2$s" rel="author external">%3$s</a>',
            esc_url(get_the_author_meta('url')),
            /* translators: %s: author's display name */
            esc_attr(sprintf(__('Visit %s&#8217;s website'), get_the_author())),
            get_the_author()
        );
    } else {
        return get_the_author();
    }
}

WordPress Version: 4.7

/**
 * Retrieve either author's link or author's name.
 *
 * If the author has a home page set, return an HTML link, otherwise just return the
 * author's name.
 *
 * @return string|null An HTML link if the author's url exist in user meta,
 *                     else the result of get_the_author().
 */
function get_the_author_link()
{
    if (get_the_author_meta('url')) {
        return sprintf(
            '<a href="%1$s" title="%2$s" rel="author external">%3$s</a>',
            esc_url(get_the_author_meta('url')),
            /* translators: %s: author's display name */
            esc_attr(sprintf(__('Visit %s&#8217;s website'), get_the_author())),
            get_the_author()
        );
    } else {
        return get_the_author();
    }
}

WordPress Version: 4.3

/**
 * Retrieve either author's link or author's name.
 *
 * If the author has a home page set, return an HTML link, otherwise just return the
 * author's name.
 *
 * @return string|null An HTML link if the author's url exist in user meta,
 *                     else the result of get_the_author().
 */
function get_the_author_link()
{
    if (get_the_author_meta('url')) {
        return '<a href="' . esc_url(get_the_author_meta('url')) . '" title="' . esc_attr(sprintf(__("Visit %s&#8217;s website"), get_the_author())) . '" rel="author external">' . get_the_author() . '</a>';
    } else {
        return get_the_author();
    }
}

WordPress Version: 4.1

/**
 * Retrieve either author's link or author's name.
 *
 * If the author has a home page set, return an HTML link, otherwise just return the
 * author's name.
 */
function get_the_author_link()
{
    if (get_the_author_meta('url')) {
        return '<a href="' . esc_url(get_the_author_meta('url')) . '" title="' . esc_attr(sprintf(__("Visit %s&#8217;s website"), get_the_author())) . '" rel="author external">' . get_the_author() . '</a>';
    } else {
        return get_the_author();
    }
}

WordPress Version: 3.7

/**
 * Retrieve either author's link or author's name.
 *
 * If the author has a home page set, return an HTML link, otherwise just return the
 * author's name.
 *
 * @uses get_the_author_meta()
 * @uses get_the_author()
 */
function get_the_author_link()
{
    if (get_the_author_meta('url')) {
        return '<a href="' . esc_url(get_the_author_meta('url')) . '" title="' . esc_attr(sprintf(__("Visit %s&#8217;s website"), get_the_author())) . '" rel="author external">' . get_the_author() . '</a>';
    } else {
        return get_the_author();
    }
}