Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_pages

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
4398           $last_changed = microtime();
4399           wp_cache_set( 'last_changed', $last_changed, 'posts' );
4400      }
4401
4402      $cache_key = "get_pages:$key:$last_changed";
4403      if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
4404           // Convert to WP_Post instances.
4405           $pages = array_map( 'get_post', $cache );
4406           /** This filter is documented in wp-includes/post.php */
4407           $pages = apply_filters( 'get_pages', $pages, $r );
4408           return $pages;
4409      }
4410
4411      $inclusions = '';
4412      if ( ! empty( $r['include'] ) ) {
4413           $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
4414           $parent = -1;
4415           $exclude = '';
4416           $meta_key = '';
 
Line Code
4540
4541      if ( ! empty( $number ) ) {
4542           $query .= ' LIMIT ' . $offset . ',' . $number;
4543      }
4544
4545      $pages = $wpdb->get_results($query);
4546
4547      if ( empty($pages) ) {
4548           /** This filter is documented in wp-includes/post.php */
4549           $pages = apply_filters( 'get_pages', array(), $r );
4550           return $pages;
4551      }
4552
4553      // Sanitize before caching so it'll only get done once.
4554      $num_pages = count($pages);
4555      for ($i = 0; $i < $num_pages; $i++) {
4556           $pages[$i] = sanitize_post($pages[$i], 'raw');
4557      }
4558
 
Line Code
4592
4593      /**
4594       * Filter the retrieved list of pages.
4595       *
4596       * @since 2.1.0
4597       *
4598       * @param array $pages List of pages to retrieve.
4599       * @param array $r     Array of get_pages() arguments.
4600       */
4601      return apply_filters( 'get_pages', $pages, $r );
4602 }
4603
4604 //
4605 // Attachment functions
4606 //
4607
4608 /**
4609  * Check if the attachment URI is local one and is really an attachment.
4610  *