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
5566      $key          = md5( serialize( wp_array_slice_assoc( $parsed_args, array_keys( $defaults ) ) ) );
5567      $last_changed = wp_cache_get_last_changed( 'posts' );
5568
5569      $cache_key = "get_pages:$key:$last_changed";
5570      $cache     = wp_cache_get( $cache_key, 'posts' );
5571      if ( false !== $cache ) {
5572           // Convert to WP_Post instances.
5573           $pages = array_map( 'get_post', $cache );
5574           /** This filter is documented in wp-includes/post.php */
5575           $pages = apply_filters( 'get_pages', $pages, $parsed_args );
5576           return $pages;
5577      }
5578
5579      $inclusions = '';
5580      if ( ! empty( $parsed_args['include'] ) ) {
5581           $child_of     = 0; // Ignore child_of, parent, exclude, meta_key, and meta_value params if using include.
5582           $parent       = -1;
5583           $exclude      = '';
5584           $meta_key     = '';
 
Line Code
5726           $query .= ' LIMIT ' . $offset . ',' . $number;
5727      }
5728
5729      $pages = $wpdb->get_results( $query );
5730
5731      if ( empty( $pages ) ) {
5732           wp_cache_set( $cache_key, array(), 'posts' );
5733
5734           /** This filter is documented in wp-includes/post.php */
5735           $pages = apply_filters( 'get_pages', array(), $parsed_args );
5736           return $pages;
5737      }
5738
5739      // Sanitize before caching so it'll only get done once.
5740      $num_pages = count( $pages );
5741      for ( $i = 0; $i < $num_pages; $i++ ) {
5742           $pages[ $i ] = sanitize_post( $pages[ $i ], 'raw' );
5743      }
5744
 
Line Code
5778
5779      /**
5780       * Filters the retrieved list of pages.
5781       *
5782       * @since 2.1.0
5783       *
5784       * @param WP_Post[] $pages       Array of page objects.
5785       * @param array     $parsed_args Array of get_pages() arguments.
5786       */
5787      return apply_filters( 'get_pages', $pages, $parsed_args );
5788 }
5789
5790 //
5791 // Attachment functions.
5792 //
5793
5794 /**
5795  * Determines whether an attachment URI is local and really an attachment.
5796  *