Make WordPress Core

Opened 17 months ago

Last modified 17 months ago

#57702 new enhancement

Default to current global post's author in `get_author_posts_url()`.

Reported by: peterwilsoncc's profile peterwilsoncc Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch
Focuses: Cc:

Description

The author of the current post is the default user in the function get_the_author_meta().

get_the_author_meta( 'display_name' ) will return the display name of the current global post's author. get_the_author_meta( 'display_name', 1260288 ) will return the display name of user 1260288 regardless of the post object.

This quirk of WordPress allows developers to determine if the requested user data is for the current post or another purpose when using the get_the_author_{$field} filter.

This behavior is not present in get_author_posts_url(), thereby making obtaining a filtering URLs of the current post's author more difficult. For the sake of consistency, it would be good to introduce the default value and match the pattern.

This change would require adding the $original_url argument to the author_link filter.

Change History (1)

This ticket was mentioned in PR #4060 on WordPress/wordpress-develop by @tanjimtc71.


17 months ago
#1

  • Keywords has-patch added

Introduces the $original_url argument to the author_link filter to allow for filtering of the author's page URL. This change brings consistency with get_the_author_meta() and allows developers to easily filter URLs for the current post's author.

Trac ticket: https://core.trac.wordpress.org/ticket/57702

Note: See TracTickets for help on using tickets.