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
4549           $last_changed = microtime();
4550           wp_cache_set( 'last_changed', $last_changed, 'posts' );
4551      }
4552
4553      $cache_key = "get_pages:$key:$last_changed";
4554      if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
4555           // Convert to WP_Post instances.
4556           $pages = array_map( 'get_post', $cache );
4557           /** This filter is documented in wp-includes/post.php */
4558           $pages = apply_filters( 'get_pages', $pages, $r );
4559           return $pages;
4560      }
4561
4562      $inclusions = '';
4563      if ( ! empty( $r['include'] ) ) {
4564           $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
4565           $parent = -1;
4566           $exclude = '';
4567           $meta_key = '';
 
Line Code
4691
4692      if ( ! empty( $number ) ) {
4693           $query .= ' LIMIT ' . $offset . ',' . $number;
4694      }
4695
4696      $pages = $wpdb->get_results($query);
4697
4698      if ( empty($pages) ) {
4699           /** This filter is documented in wp-includes/post.php */
4700           $pages = apply_filters( 'get_pages', array(), $r );
4701           return $pages;
4702      }
4703
4704      // Sanitize before caching so it'll only get done once.
4705      $num_pages = count($pages);
4706      for ($i = 0; $i < $num_pages; $i++) {
4707           $pages[$i] = sanitize_post($pages[$i], 'raw');
4708      }
4709
 
Line Code
4743
4744      /**
4745       * Filter the retrieved list of pages.
4746       *
4747       * @since 2.1.0
4748       *
4749       * @param array $pages List of pages to retrieve.
4750       * @param array $r     Array of get_pages() arguments.
4751       */
4752      return apply_filters( 'get_pages', $pages, $r );
4753 }
4754
4755 //
4756 // Attachment functions
4757 //
4758
4759 /**
4760  * Check if the attachment URI is local one and is really an attachment.
4761  *