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
4463           $last_changed = microtime();
4464           wp_cache_set( 'last_changed', $last_changed, 'posts' );
4465      }
4466
4467      $cache_key = "get_pages:$key:$last_changed";
4468      if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
4469           // Convert to WP_Post instances.
4470           $pages = array_map( 'get_post', $cache );
4471           /** This filter is documented in wp-includes/post.php */
4472           $pages = apply_filters( 'get_pages', $pages, $r );
4473           return $pages;
4474      }
4475
4476      $inclusions = '';
4477      if ( ! empty( $r['include'] ) ) {
4478           $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
4479           $parent = -1;
4480           $exclude = '';
4481           $meta_key = '';
 
Line Code
4605
4606      if ( ! empty( $number ) ) {
4607           $query .= ' LIMIT ' . $offset . ',' . $number;
4608      }
4609
4610      $pages = $wpdb->get_results($query);
4611
4612      if ( empty($pages) ) {
4613           /** This filter is documented in wp-includes/post.php */
4614           $pages = apply_filters( 'get_pages', array(), $r );
4615           return $pages;
4616      }
4617
4618      // Sanitize before caching so it'll only get done once.
4619      $num_pages = count($pages);
4620      for ($i = 0; $i < $num_pages; $i++) {
4621           $pages[$i] = sanitize_post($pages[$i], 'raw');
4622      }
4623
 
Line Code
4657
4658      /**
4659       * Filter the retrieved list of pages.
4660       *
4661       * @since 2.1.0
4662       *
4663       * @param array $pages List of pages to retrieve.
4664       * @param array $r     Array of get_pages() arguments.
4665       */
4666      $pages = apply_filters( 'get_pages', $pages, $r );
4667
4668      return $pages;
4669 }
4670
4671 //
4672 // Attachment functions
4673 //
4674
4675 /**