WordPress at a glance

get_all_page_ids() WP 1.0

Get a list of page IDs.

  • Global. wpdb. $wpdb WordPress database abstraction object.

No Hooks.


Array. List of page IDs.



Code of get all page ids: wp-includes/post.php VER 5.0.3

function get_all_page_ids() {
	global $wpdb;

	$page_ids = wp_cache_get('all_page_ids', 'posts');
	if ( ! is_array( $page_ids ) ) {
		$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'");
		wp_cache_add('all_page_ids', $page_ids, 'posts');

	return $page_ids;

Related Functions

From category: Pages

No comments
    Hello, !     Log In . Register