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
5783
5784      $cache_key = "get_pages:$key:$last_changed";
5785      $cache     = wp_cache_get( $cache_key, 'posts' );
5786      if ( false !== $cache ) {
5787           _prime_post_caches( $cache, false, false );
5788
5789           // Convert to WP_Post instances.
5790           $pages = array_map( 'get_post', $cache );
5791           /** This filter is documented in wp-includes/post.php */
5792           $pages = apply_filters( 'get_pages', $pages, $parsed_args );
5793
5794           return $pages;
5795      }
5796
5797      $inclusions = '';
5798      if ( ! empty( $parsed_args['include'] ) ) {
5799           $child_of     = 0; // Ignore child_of, parent, exclude, meta_key, and meta_value params if using include.
5800           $parent       = -1;
5801           $exclude      = '';
 
Line Code
5944           $query .= ' LIMIT ' . $offset . ',' . $number;
5945      }
5946
5947      $pages = $wpdb->get_results( $query );
5948
5949      if ( empty( $pages ) ) {
5950           wp_cache_set( $cache_key, array(), 'posts' );
5951
5952           /** This filter is documented in wp-includes/post.php */
5953           $pages = apply_filters( 'get_pages', array(), $parsed_args );
5954
5955           return $pages;
5956      }
5957
5958      // Sanitize before caching so it'll only get done once.
5959      $num_pages = count( $pages );
5960      for ( $i = 0; $i < $num_pages; $i++ ) {
5961           $pages[ $i ] = sanitize_post( $pages[ $i ], 'raw' );
5962      }
 
Line Code
5997
5998      /**
5999       * Filters the retrieved list of pages.
6000       *
6001       * @since 2.1.0
6002       *
6003       * @param WP_Post[] $pages       Array of page objects.
6004       * @param array     $parsed_args Array of get_pages() arguments.
6005       */
6006      return apply_filters( 'get_pages', $pages, $parsed_args );
6007 }
6008
6009 //
6010 // Attachment functions.
6011 //
6012
6013 /**
6014  * Determines whether an attachment URI is local and really an attachment.
6015  *