Check the source code in the Code Reference. Even if it didn’t, there’s little you can do unless the function accepts the post ID as a parameter. A global declaration in your code is out of scope to functions. And declarations within functions are out of scope for your code.
It may seem odd that globals can be out of scope. It’s not the global itself, but the declaration. Globals are indeed global, but they need to be declared, and declarations are subject to scoping rules. It’s how PHP works. Other languages handle globals differently.
It gets weirder. You’ll see in the above link that $post is in fact not declared global. A related global $authordata is where the function gets its data. Both globals, and a few more, are all set when the_post() is called at the start of each loop. But you will not find the declaration in that source code either. the_post() merely calls WP_Query::the_post(), which does declare $post global. But where’s the global $authordata and the others I mentioned? Farther down, WP_Query::setup_postdata() is called, where you will finally see global $authordata and its many relatives declared. Whew!
Clearly, checking source code can get pretty convoluted. It’s not unheard of to drill down through a half dozen sub-functions before you reach what you’re looking for. I’ve found the Uses and Used By sections below the source code very useful in finding what I need in source.
I’m not sure I’m following what you’re asking about author_link
link name. This filter only affects the URL used, the part assigned to the anchor tag’s href attribute. Anything else about the link is managed elsewhere. Is it something in the URL you want to change, or is it the link text that appears on the page? I think you mean the link text. In that case, look on the responsible template for how that is determined.
If it’s not a static string like “Author’s Posts”, it’s probably another function like get_the_author_meta('display_name')
. Find the function’s source code and see if there is a filter applied to the return value. If there is, hook that filter and return your desired value. Or alter the template code to get the value through some other means.