Support » Plugins » Hacks » add_filter('the_author_link','…'); – does it exist?

  • Resolved Gengar003

    (@gengar003)


    I have a plugin that I want to change the place that users are taken to if they click an author’s name.

    The obvious way to do this, I figured, would be to filter on “the_author_link,” and change the link.

    However, there does not seem to be a hook for “the_author_link,” – there seems to only be a hook for “the_author.”

    This works, in that I can filter on “the_author,” and wrap the author name in a link, and it links to where I want.

    However, what’s really going on is this:

    <a href='the original the_author_link_url'>
    
    <a href='my new URL'>Author's Name</a>
    
    </a>

    A link inside a link is not valid markup. Thus, while my plugin will work and behave the way I want if I use this method, I cannot make it valid HTML, XHTML, or anything.

    My question, then, is twofold:

    1. Is there, or is there not, a hook to add_filter on ‘the_author_link’?

    2. If there is no such hook, how do I go about correctly implementing a change to the behavior of the_author_link(); ?

    Thank you for your time.

Viewing 2 replies - 1 through 2 (of 2 total)
  • See wp-includes/author-template.php, there are quite a few hooks.. this one should be suited for what you want..

    add_filter( 'get_the_author_url', 'your_filter', 10, 2 );
    
    function your_filter( $_author_url, $_author_id ) {
    
    	// Do stuff - $_author_url is the given author's existing URL
    
    	// Leave this line, data must be returned, just do what you want with it above
    	return $_author_url;
    }

    Hope that helps…

    Yes, that is what I needed; thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add_filter('the_author_link','…'); – does it exist?’ is closed to new replies.