Title: WP_List_Table::set_pagination_args
Published: April 25, 2014
Last modified: August 20, 2026

---

# WP_List_Table::set_pagination_args( array|string $args )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_list_table/set_pagination_args/?output_format=md#parameters)
 * [More Information](https://developer.wordpress.org/reference/classes/wp_list_table/set_pagination_args/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/classes/wp_list_table/set_pagination_args/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_list_table/set_pagination_args/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_list_table/set_pagination_args/?output_format=md#changelog)

Sets all the necessary pagination arguments.

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

 `$args`array|stringrequired

Array or string of arguments with information about the pagination.

## 󠀁[More Information](https://developer.wordpress.org/reference/classes/wp_list_table/set_pagination_args/?output_format=md#more-information)󠁿

  This method should be called internally (usually from prepare_items()) to set 
basic pagination arguments. Available arguments include:

 * **total_items** – the total number of items to be displayed. Usually as simple
   as count($data)
 * **per_page** – the number of items to show per page
 * **total_pages** – the total number of pages. Can be left blank or calculated 
   manually, like so: ceil($total_items/$per_page)

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

    ```php
    protected function set_pagination_args( $args ) {
    	$args = wp_parse_args(
    		$args,
    		array(
    			'total_items' => 0,
    			'total_pages' => 0,
    			'per_page'    => 0,
    		)
    	);

    	if ( ! $args['total_pages'] && $args['per_page'] > 0 ) {
    		$args['total_pages'] = (int) ceil( $args['total_items'] / $args['per_page'] );
    	}

    	// Redirect if page number is invalid and headers are not already sent.
    	if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
    		wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
    		exit;
    	}

    	$this->_pagination_args = $args;
    }
    ```

[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.1/src/wp-admin/includes/class-wp-list-table.php#L323)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/class-wp-list-table.php#L323-L344)

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

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

Determines whether the current request is a WordPress Ajax request.

  | 
| [WP_List_Table::get_pagenum()](https://developer.wordpress.org/reference/classes/wp_list_table/get_pagenum/)`wp-admin/includes/class-wp-list-table.php` |

Gets the current page number.

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

Redirects to another page.

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

Merges user defined arguments into defaults array.

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

Retrieves a modified URL query string.

  |

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

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

| Version | Description | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.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%2Fset_pagination_args%2F)
before being able to contribute a note or feedback.