functions - What does the author_nicename parameter do in get_author_posts_url()?

I was looking at get_author_posts_url() which takes the user id as a param and returns a URL. It has an optional second

I was looking at get_author_posts_url() which takes the user id as a param and returns a URL. It has an optional second parameter $author_nicename.

get_author_posts_url( $author_id, $author_nicename );

What does providing $author_nicename do exactly?

I was looking at get_author_posts_url() which takes the user id as a param and returns a URL. It has an optional second parameter $author_nicename.

get_author_posts_url( $author_id, $author_nicename );

What does providing $author_nicename do exactly?

Share Improve this question asked Jun 13, 2019 at 9:45 Matthew Brown aka Lord MattMatthew Brown aka Lord Matt 1,0683 gold badges13 silver badges34 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

Say that get_author_posts_url(1) return the following URL

https://example/author/admin/

Passing the $author_nicename will change this. So get_author_posts_url(1, 'foo') will result in

https://example/author/foo/

You can also check this in the source code of get_author_posts_url().


So what does passing the second argument do? It changes the resulting URL. If you don't provide further mechanisms, this will probably result in invalid URLs.

Why is this provided? No idea.

Ok, so checking this file via Git blame turns out, get_author_posts_url() was previously called get_author_link() (this change happened on Aug 30, 2006). get_author_link() was added on Mar 19, 2004 and required the argument $author_nicename (though it had a fallback).

Why is this provided? Because in earlier times, you needed to pass the (correct) nicename for this to work.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745405709a4626304.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信