WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom display of meta-info (authors name, date and categories). So, I want to display a custom link to all posts by author. By theme default I have this <?php the_author_posts_link(); ?> which displays author name and if you press on it you get what I want. On the index.php actually it is what I want, but on single.php I would like to have something like "view all pages by author" text and if you would press on it, it should do exactly the same as adding <?php the_author_posts_link(); ?>. where should I start with this issue? Thanks!

share|improve this question
You can't do that if your blog is hosted on wordpress.com – scribu Aug 12 '11 at 13:21
I have a custom host – user385917 Aug 12 '11 at 13:24
Then why did you tag the question with 'wordpress.com'? Anyway... – scribu Aug 12 '11 at 13:27

Attach a filter that only outputs a different link when you're on single.php:

function wpse25725_author_posts( $link )
    // abort if not on single.php
    if ( ! is_single() )

    // modify this as you like - so far exactly the same as in the original core function
    // if you simply want to add something to the existing link, use ".=" instead of "=" for $link
    $link = sprintf(
        '<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
        get_author_posts_url( $authordata->ID, $authordata->user_nicename ),
        esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ),

    return $link;
add_filter( 'the_author_posts_link', 'wpse25725_author_posts' );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.