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
2074           'authors' => '', 'parent' => -1, 'exclude_tree' => ''
2075      );
2076
2077      $r = wp_parse_args( $args, $defaults );
2078      extract( $r, EXTR_SKIP );
2079
2080      $key = md5( serialize( compact(array_keys($defaults)) ) );
2081      if ( $cache = wp_cache_get( 'get_pages', 'posts' ) ) {
2082           if ( isset( $cache[ $key ] ) ) {
2083                $pages = apply_filters('get_pages', $cache[ $key ], $r );
2084                return $pages;
2085           }
2086      }
2087
2088      $inclusions = '';
2089      if ( !empty($include) ) {
2090           $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
2091           $parent = -1;
2092           $exclude = '';
 
Line Code
2166           $where .= $wpdb->prepare(' AND post_parent = %d ', $parent);
2167
2168      $query = "SELECT * FROM $wpdb->posts $join WHERE (post_type = 'page' AND post_status = 'publish') $where ";
2169      $query .= $author_query;
2170      $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
2171
2172      $pages = $wpdb->get_results($query);
2173
2174      if ( empty($pages) ) {
2175           $pages = apply_filters('get_pages', array(), $r);
2176           return $pages;
2177      }
2178
2179      // Update cache.
2180      update_page_cache($pages);
2181
2182      if ( $child_of || $hierarchical )
2183           $pages = & get_page_children($child_of, $pages);
2184
 
Line Code
2195           for ( $i = 0; $i < $total; $i++ ) {
2196                if ( in_array($pages[$i]->ID, $excludes) )
2197                     unset($pages[$i]);
2198           }
2199      }
2200
2201      $cache[ $key ] = $pages;
2202      wp_cache_set( 'get_pages', $cache, 'posts' );
2203
2204      $pages = apply_filters('get_pages', $pages, $r);
2205
2206      return $pages;
2207 }
2208
2209 //
2210 // Attachment functions
2211 //
2212
2213 /**