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
6013
6014      $cache_key = "get_pages:$key:$last_changed";
6015      $cache     = wp_cache_get( $cache_key, 'posts' );
6016      if ( false !== $cache ) {
6017           _prime_post_caches( $cache, false, false );
6018
6019           // Convert to WP_Post instances.
6020           $pages = array_map( 'get_post', $cache );
6021           /** This filter is documented in wp-includes/post.php */
6022           $pages = apply_filters( 'get_pages', $pages, $parsed_args );
6023
6024           return $pages;
6025      }
6026
6027      $inclusions = '';
6028      if ( ! empty( $parsed_args['include'] ) ) {
6029           $child_of     = 0; // Ignore child_of, parent, exclude, meta_key, and meta_value params if using include.
6030           $parent       = -1;
6031           $exclude      = '';
 
Line Code
6174           $query .= ' LIMIT ' . $offset . ',' . $number;
6175      }
6176
6177      $pages = $wpdb->get_results( $query );
6178
6179      if ( empty( $pages ) ) {
6180           wp_cache_set( $cache_key, array(), 'posts' );
6181
6182           /** This filter is documented in wp-includes/post.php */
6183           $pages = apply_filters( 'get_pages', array(), $parsed_args );
6184
6185           return $pages;
6186      }
6187
6188      // Sanitize before caching so it'll only get done once.
6189      $num_pages = count( $pages );
6190      for ( $i = 0; $i < $num_pages; $i++ ) {
6191           $pages[ $i ] = sanitize_post( $pages[ $i ], 'raw' );
6192      }
 
Line Code
6227
6228      /**
6229       * Filters the retrieved list of pages.
6230       *
6231       * @since 2.1.0
6232       *
6233       * @param WP_Post[] $pages       Array of page objects.
6234       * @param array     $parsed_args Array of get_pages() arguments.
6235       */
6236      return apply_filters( 'get_pages', $pages, $parsed_args );
6237 }
6238
6239 //
6240 // Attachment functions.
6241 //
6242
6243 /**
6244  * Determines whether an attachment URI is local and really an attachment.
6245  *