WordPress.org

Ready to get started?Download WordPress

Forums

how to add_filter on get_the_author_link (1 post)

  1. Julio Potier
    Member
    Posted 2 years ago #

    Hello

    I'm trying to add a filter on get_the_author_link or the_author_link.

    This is the function from author-template.php :

    function get_the_author_link() {
    	if ( get_the_author_meta('url') ) {
    		return '<a href="' . get_the_author_meta('url') . '" title="' . esc_attr( sprintf(__("Visit %s’s website"), get_the_author()) ) . '" rel="external">' . get_the_author() . '</a>';
    	} else {
    		return get_the_author();
    	}
    }

    if get_the_author_meta('url') is empty, only the author name will be returned.

    I want to add a filter to add another link. Function like this :

    function my_get_the_author_link() {
    	if ( get_the_author_meta('url') ) {
    		return '<a href="' . get_the_author_meta('url') . '" title="' . esc_attr( sprintf(__("Visit %s’s website"), get_the_author()) ) . '" rel="author">' . get_the_author() . '</a>';
    	} else {
    		return '<a href="' . home_url() . '/author/. get_the_author_meta('ID') . " title="' . esc_attr( sprintf(__("Visit %s’s website"), get_the_author()) ) . '" rel="author">' . get_the_author() . '</a>';
    	}
    }

    So i NEED to filter this function, because i need to modify too the "rel" microformat oncluded in the A tag.

    Thank you :)

Topic Closed

This topic has been closed to new replies.

About this Topic