In the Twenty twelve theme, the twentytwelve_entry_meta() function shows "by-author" links (i.e., the ones that have the title "View all posts by xxxx") by using user_nicename. So when a "difficult" admin username is chosen, that link can look something like:

<a href="http://example.com/author/site_admin_45471/">John Smith</a>

Is there any way to change that twentytwelve_entry_meta() function, and keep the link to the author's other posts, but use something other than the "user_nicename" in the body of the link? E.g.:

<a href="http://example.com/author/author_id/">John Smith</a>


My (slightly altered from default) twentytwelve_entry_meta() function:

function twentytwelve_entry_meta() {
// Translators: used between list items, there is a space after the comma.
$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );

// Translators: used between list items, there is a space after the comma.
$tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );

$date = sprintf( '<time class="entry-date" datetime="%3$s">%4$s</time>',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )

$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),

// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
if ( $tag_list ) {
$utility_text = __( 'Posted on %3$s<span class="by-author"> by %4$s</span>', 'twentytwelve' );
} elseif ( $categories_list ) {
$utility_text = __( 'Posted on %3$s<span class="by-author"> by %4$s</span>', 'twentytwelve' );
} else {
$utility_text = __( 'Posted on %3$s<span class="by-author"> by %4$s</span>', 'twentytwelve' );


The rewrite function from the apparently duplicated question:

// add our custom rewrite rules for author archives
add_action('author_rewrite_rules', 'my_author_rewrite_rules');

function my_author_rewrite_rules() {
$author_rules['author/([0-9]+)/?$'] = 'index.php?author=$matches[1]';
$author_rules['author/([0-9]+)/page/?([0-9]{1,})/?$'] = 'index.php?author=$matches[1]&paged=$matches[2]';
$author_rules['author/([0-9]+)/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?author=$matches[1]&feed=$matches[2]';
$author_rules['author/([0-9]+)/feed/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?author=$matches[1]&feed=$matches[2]';
return $author_rules;

After this I re-saved permalinks. Following this, the author URL hasn't changed; furthermore, clicking the URL now returns a 404. Not sure if I have to further modify the twentytwelve_entry_meta() function after adding the my_author_rewrite_rules() function ?

  • possible duplicate of How to Change Author Posts URL
    – s_ha_dum
    Jan 23, 2014 at 14:11
  • First, that function can be overwritten simply by creating a function of your own of the same name in a child theme, which is the proper way to modify the theme. Second, it looks to me like the URL for that link is generated here: get_author_posts_url( get_the_author_meta( 'ID' ) ). So, what you are really asking is "Can I alter the author posts link?".
    – s_ha_dum
    Jan 23, 2014 at 14:11
  • I am rewriting that function with a replacement in my child theme's functions.php - it's just that I don't know how to accomplish that particular aspect of it.
    – John Doe
    Jan 23, 2014 at 14:23
  • See the post marked as a duplicate.
    – s_ha_dum
    Jan 23, 2014 at 14:29
  • I placed that function in my child theme's functions.php but nothing appears to have changed. I'm missing something.
    – John Doe
    Jan 23, 2014 at 14:38

1 Answer 1


Well for anyone who may be interested, I worked out that the answer, after adding the my_author_rewrite_rules function as above (thank you), is to edit the twentytwelve_entry_meta() function by replacing this:

esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),

with this:

esc_url( sprintf( __( home_url().'/author/%d', 'twentytwelve' ), get_the_author_meta('ID') ) ),

It also means similarly changing the code underneath the archive-header class in the author.php file.

  • I guess that could be site_url() in certain configurations.
    – John Doe
    Jan 25, 2014 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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