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
4590           $last_changed = microtime();
4591           wp_cache_set( 'last_changed', $last_changed, 'posts' );
4592      }
4593
4594      $cache_key = "get_pages:$key:$last_changed";
4595      if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
4596           // Convert to WP_Post instances.
4597           $pages = array_map( 'get_post', $cache );
4598           /** This filter is documented in wp-includes/post.php */
4599           $pages = apply_filters( 'get_pages', $pages, $r );
4600           return $pages;
4601      }
4602
4603      $inclusions = '';
4604      if ( ! empty( $r['include'] ) ) {
4605           $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
4606           $parent = -1;
4607           $exclude = '';
4608           $meta_key = '';
 
Line Code
4732
4733      if ( ! empty( $number ) ) {
4734           $query .= ' LIMIT ' . $offset . ',' . $number;
4735      }
4736
4737      $pages = $wpdb->get_results($query);
4738
4739      if ( empty($pages) ) {
4740           /** This filter is documented in wp-includes/post.php */
4741           $pages = apply_filters( 'get_pages', array(), $r );
4742           return $pages;
4743      }
4744
4745      // Sanitize before caching so it'll only get done once.
4746      $num_pages = count($pages);
4747      for ($i = 0; $i < $num_pages; $i++) {
4748           $pages[$i] = sanitize_post($pages[$i], 'raw');
4749      }
4750
 
Line Code
4784
4785      /**
4786       * Filter the retrieved list of pages.
4787       *
4788       * @since 2.1.0
4789       *
4790       * @param array $pages List of pages to retrieve.
4791       * @param array $r     Array of get_pages() arguments.
4792       */
4793      return apply_filters( 'get_pages', $pages, $r );
4794 }
4795
4796 //
4797 // Attachment functions
4798 //
4799
4800 /**
4801  * Check if the attachment URI is local one and is really an attachment.
4802  *