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
4510           $last_changed = microtime();
4511           wp_cache_set( 'last_changed', $last_changed, 'posts' );
4512      }
4513
4514      $cache_key = "get_pages:$key:$last_changed";
4515      if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
4516           // Convert to WP_Post instances.
4517           $pages = array_map( 'get_post', $cache );
4518           /** This filter is documented in wp-includes/post.php */
4519           $pages = apply_filters( 'get_pages', $pages, $r );
4520           return $pages;
4521      }
4522
4523      $inclusions = '';
4524      if ( ! empty( $r['include'] ) ) {
4525           $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
4526           $parent = -1;
4527           $exclude = '';
4528           $meta_key = '';
 
Line Code
4652
4653      if ( ! empty( $number ) ) {
4654           $query .= ' LIMIT ' . $offset . ',' . $number;
4655      }
4656
4657      $pages = $wpdb->get_results($query);
4658
4659      if ( empty($pages) ) {
4660           /** This filter is documented in wp-includes/post.php */
4661           $pages = apply_filters( 'get_pages', array(), $r );
4662           return $pages;
4663      }
4664
4665      // Sanitize before caching so it'll only get done once.
4666      $num_pages = count($pages);
4667      for ($i = 0; $i < $num_pages; $i++) {
4668           $pages[$i] = sanitize_post($pages[$i], 'raw');
4669      }
4670
 
Line Code
4704
4705      /**
4706       * Filter the retrieved list of pages.
4707       *
4708       * @since 2.1.0
4709       *
4710       * @param array $pages List of pages to retrieve.
4711       * @param array $r     Array of get_pages() arguments.
4712       */
4713      $pages = apply_filters( 'get_pages', $pages, $r );
4714
4715      return $pages;
4716 }
4717
4718 //
4719 // Attachment functions
4720 //
4721
4722 /**