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
5984
5985      $cache_key = "get_pages:$key:$last_changed";
5986      $cache     = wp_cache_get( $cache_key, 'posts' );
5987      if ( false !== $cache ) {
5988           _prime_post_caches( $cache, false, false );
5989
5990           // Convert to WP_Post instances.
5991           $pages = array_map( 'get_post', $cache );
5992           /** This filter is documented in wp-includes/post.php */
5993           $pages = apply_filters( 'get_pages', $pages, $parsed_args );
5994
5995           return $pages;
5996      }
5997
5998      $inclusions = '';
5999      if ( ! empty( $parsed_args['include'] ) ) {
6000           $child_of     = 0; // Ignore child_of, parent, exclude, meta_key, and meta_value params if using include.
6001           $parent       = -1;
6002           $exclude      = '';
 
Line Code
6145           $query .= ' LIMIT ' . $offset . ',' . $number;
6146      }
6147
6148      $pages = $wpdb->get_results( $query );
6149
6150      if ( empty( $pages ) ) {
6151           wp_cache_set( $cache_key, array(), 'posts' );
6152
6153           /** This filter is documented in wp-includes/post.php */
6154           $pages = apply_filters( 'get_pages', array(), $parsed_args );
6155
6156           return $pages;
6157      }
6158
6159      // Sanitize before caching so it'll only get done once.
6160      $num_pages = count( $pages );
6161      for ( $i = 0; $i < $num_pages; $i++ ) {
6162           $pages[ $i ] = sanitize_post( $pages[ $i ], 'raw' );
6163      }
 
Line Code
6198
6199      /**
6200       * Filters the retrieved list of pages.
6201       *
6202       * @since 2.1.0
6203       *
6204       * @param WP_Post[] $pages       Array of page objects.
6205       * @param array     $parsed_args Array of get_pages() arguments.
6206       */
6207      return apply_filters( 'get_pages', $pages, $parsed_args );
6208 }
6209
6210 //
6211 // Attachment functions.
6212 //
6213
6214 /**
6215  * Determines whether an attachment URI is local and really an attachment.
6216  *