I'm trying to create a WP-based website with lots of documents about various people from different dates. I would like to have a dedicated page for each individual where there'll be links to display the posts about that person from a specific year.

Could you help me find a way to do this?

Thank you!

  • Could you explain more things as I am confused with your question Jan 22, 2015 at 8:58
  • Imagine an aggregation of news articles concerning different public figures - those are all added as "posts" in Wordpress, nothing fancy there. Now, imagine a "page", dedicated to one of these individuals - it has a name, brief bio, etc. And after that a list of links like this: "1990, 1991, 1992..." When you click on one of those, you get a list of posts tagged with that individual's name, but only from the specified year. Is it doable?
    – zkvvoob
    Jan 22, 2015 at 9:05
  • I reckon this has to be done with a search query, but I do not know how exactly to achieve this result.
    – zkvvoob
    Jan 22, 2015 at 9:07

1 Answer 1


Check out wp_get_archives().

As described by the Function Reference linked to above, "This function displays a date-based archives list. This tag can be used anywhere within a template."

It gives several examples of how you can use the function, including if you wish to use a dropdown rather than listing every archive.

By default this function will take in to account every post, not just the ones about your author. However, you needn't fear - there are hooks that you can use to fix this. For example, you can add a specific author -

On your template add this -

$args = array(
    'author' => $author_id,  // Obviously this relies on you knowing the ID of the author
    'type' => 'yearly'

And then in functions.php

add_filter('getarchives_where', 'my_edit_getarchives_where');
function my_edit_getarchives_where($where, $args){

    if(isset($args['author']) :  // Ensure that an author has been specified
        $where.= ' AND `post_author` IN (' . $args['author'] . ')';

    return $where;


Note that while auhor is not a default argument of the wp_get_archives() function, it won't be stripped out and thus will be available for your custom use in a scenario such as that described above.

If that example doesn't quite do it for you then there are two other filter hooks that you can use

  • getarchives_join - Allows you to JOIN additional tables (so that you can link to archives of a certain category/tag).

  • the_title - You can amend the title output if you wish (place 'Archive - ' before it, for example). Not much help in your situation, but good to know about.

I'd encourage you to look through the function in question to fully understand how it works. wp_get_archives() can be found in /wp-includes/general-template.php on line 1321 (I'm using version 4.1).


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.