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