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
5443      $key          = md5( serialize( wp_array_slice_assoc( $parsed_args, array_keys( $defaults ) ) ) );
5444      $last_changed = wp_cache_get_last_changed( 'posts' );
5445
5446      $cache_key = "get_pages:$key:$last_changed";
5447      $cache     = wp_cache_get( $cache_key, 'posts' );
5448      if ( false !== $cache ) {
5449           // Convert to WP_Post instances.
5450           $pages = array_map( 'get_post', $cache );
5451           /** This filter is documented in wp-includes/post.php */
5452           $pages = apply_filters( 'get_pages', $pages, $parsed_args );
5453           return $pages;
5454      }
5455
5456      $inclusions = '';
5457      if ( ! empty( $parsed_args['include'] ) ) {
5458           $child_of     = 0; // Ignore child_of, parent, exclude, meta_key, and meta_value params if using include.
5459           $parent       = -1;
5460           $exclude      = '';
5461           $meta_key     = '';
 
Line Code
5603           $query .= ' LIMIT ' . $offset . ',' . $number;
5604      }
5605
5606      $pages = $wpdb->get_results( $query );
5607
5608      if ( empty( $pages ) ) {
5609           wp_cache_set( $cache_key, array(), 'posts' );
5610
5611           /** This filter is documented in wp-includes/post.php */
5612           $pages = apply_filters( 'get_pages', array(), $parsed_args );
5613           return $pages;
5614      }
5615
5616      // Sanitize before caching so it'll only get done once.
5617      $num_pages = count( $pages );
5618      for ( $i = 0; $i < $num_pages; $i++ ) {
5619           $pages[ $i ] = sanitize_post( $pages[ $i ], 'raw' );
5620      }
5621
 
Line Code
5655
5656      /**
5657       * Filters the retrieved list of pages.
5658       *
5659       * @since 2.1.0
5660       *
5661       * @param WP_Post[] $pages       Array of page objects.
5662       * @param array     $parsed_args Array of get_pages() arguments.
5663       */
5664      return apply_filters( 'get_pages', $pages, $parsed_args );
5665 }
5666
5667 //
5668 // Attachment functions.
5669 //
5670
5671 /**
5672  * Determines whether an attachment URI is local and really an attachment.
5673  *