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.

Return

Array. List of page IDs.

Usage

get_all_page_ids();

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

<?php
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