Title: WP_List_Table::get_views_links
Published: November 2, 2022
Last modified: May 20, 2026

---

# WP_List_Table::get_views_links( array $link_data = array() ): string[]

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_list_table/get_views_links/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_list_table/get_views_links/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_list_table/get_views_links/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_list_table/get_views_links/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_list_table/get_views_links/?output_format=md#changelog)

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

Generates views links.

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

 `$link_data`arrayoptional

An array of link data.

 * `url` string
 * The link URL.
 * `label` string
 * The link label.
 * `current` bool
 * Optional. Whether this is the currently selected view.

Default:`array()`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_list_table/get_views_links/?output_format=md#return)󠁿

 string[] An array of link markup. Keys match the `$link_data` input array.

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

    ```php
    protected function get_views_links( $link_data = array() ) {
    	if ( ! is_array( $link_data ) ) {
    		_doing_it_wrong(
    			__METHOD__,
    			sprintf(
    				/* translators: %s: The $link_data argument. */
    				__( 'The %s argument must be an array.' ),
    				'<code>$link_data</code>'
    			),
    			'6.1.0'
    		);

    		return array( '' );
    	}

    	$views_links = array();

    	foreach ( $link_data as $view => $link ) {
    		if ( empty( $link['url'] ) || ! is_string( $link['url'] ) || '' === trim( $link['url'] ) ) {
    			_doing_it_wrong(
    				__METHOD__,
    				sprintf(
    					/* translators: %1$s: The argument name. %2$s: The view name. */
    					__( 'The %1$s argument must be a non-empty string for %2$s.' ),
    					'<code>url</code>',
    					'<code>' . esc_html( $view ) . '</code>'
    				),
    				'6.1.0'
    			);

    			continue;
    		}

    		if ( empty( $link['label'] ) || ! is_string( $link['label'] ) || '' === trim( $link['label'] ) ) {
    			_doing_it_wrong(
    				__METHOD__,
    				sprintf(
    					/* translators: %1$s: The argument name. %2$s: The view name. */
    					__( 'The %1$s argument must be a non-empty string for %2$s.' ),
    					'<code>label</code>',
    					'<code>' . esc_html( $view ) . '</code>'
    				),
    				'6.1.0'
    			);

    			continue;
    		}

    		$views_links[ $view ] = sprintf(
    			'<a href="%s"%s>%s</a>',
    			esc_url( $link['url'] ),
    			isset( $link['current'] ) && true === $link['current'] ? ' class="current" aria-current="page"' : '',
    			$link['label']
    		);
    	}

    	return $views_links;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-list-table.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/class-wp-list-table.php#L426)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/class-wp-list-table.php#L426-L483)

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

| Uses | Description | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [_doing_it_wrong()](https://developer.wordpress.org/reference/functions/_doing_it_wrong/)`wp-includes/functions.php` |

Marks something as being incorrectly called.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_list_table/get_views_links/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_list_table/get_views_links/?output_format=md#)

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

| Version | Description | 
| [6.1.0](https://developer.wordpress.org/reference/since/6.1.0/) | Introduced. |

## User Contributed Notes

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