Title: get_archives_link
Published: April 25, 2014
Last modified: May 20, 2026

---

# apply_filters( ‘get_archives_link’, string $link_html, string $url, string $text, string $format, string $before, string $after, bool $selected )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#wp--skip-link--target)

Filters the archive link content.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#parameters)󠁿

 `$link_html`string

The archive HTML link content.

`$url`string

URL to archive.

`$text`string

Archive text description.

`$format`string

Link format. Can be `'link'`, `'option'`, `'html'`, or custom.

`$before`string

Content to prepend to the description.

`$after`string

Content to append to the description.

`$selected`bool

True if the current page is the selected archive.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#source)󠁿

    ```php
    return apply_filters( 'get_archives_link', $link_html, $url, $text, $format, $before, $after, $selected );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/general-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/general-template.php#L1959)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/general-template.php#L1959-L1959)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#related)󠁿

| Used by | Description | 
| [get_archives_link()](https://developer.wordpress.org/reference/functions/get_archives_link/)`wp-includes/general-template.php` |

Retrieves archive link content based on predefined or custom code.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.2.0](https://developer.wordpress.org/reference/since/5.2.0/) | Added the `$selected` parameter. | 
| [4.5.0](https://developer.wordpress.org/reference/since/4.5.0/) | Added the `$url`, `$text`, `$format`, `$before`, and `$after` parameters. | 
| [2.6.0](https://developer.wordpress.org/reference/since/2.6.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/get_archives_link/?output_format=md#comment-content-1018)
 2.   [Mário Valney](https://profiles.wordpress.org/mariovalney/)  [  10 years ago  ](https://developer.wordpress.org/reference/hooks/get_archives_link/#comment-1018)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_archives_link%2F%23comment-1018)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_archives_link%2F%23comment-1018)
 4. You can use this filter to add **current-archive** class to element (as _current-
    cat_ in **[wp_list_categories()](https://developer.wordpress.org/reference/functions/wp_list_categories/)**
    function):
 5.     ```php
        function example_get_archives_link($link_html) {
            if (is_day() || is_month() || is_year()) {
                if (is_day()) {
                    $data = get_the_time('Y/m/d');
                } elseif (is_month()) {
                    $data = get_the_time('Y/m');
                } elseif (is_year()) {
                    $data = get_the_time('Y');
                }
    
                // Link to archive page
                $link = home_url($data);
    
                // Check if the link is in string
                $strpos = strpos($link_html, $link);
    
                // Add class if link has been found
                if ($strpos !== false) {
                    $link_html = str_replace('<li>', '<li class="current-archive">', $link_html);
                }
            }
    
            return $link_html;
        }
        add_filter("get_archives_link", "example_get_archives_link");
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_archives_link%2F%3Freplytocom%3D1018%23feedback-editor-1018)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_archives_link%2F)
before being able to contribute a note or feedback.