Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_previous_post_where

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

Line Code
291           foreach ( $blah as $category ) {
292                $category = intval($category);
293                $sql_cat_ids = " OR pc.category_ID = '$category'";
294           }
295           $posts_in_ex_cats = $wpdb->get_col("SELECT p.ID FROM $wpdb->posts p LEFT JOIN $wpdb->post2cat pc ON pc.post_id=p.ID WHERE 1 = 0 $sql_cat_ids GROUP BY p.ID");
296           $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')';
297      }
298
299      $join  = apply_filters( 'get_previous_post_join', $join, $in_same_cat, $excluded_categories );
300      $where = apply_filters( 'get_previous_post_where', "WHERE post_date < '$current_post_date' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql", $in_same_cat, $excluded_categories );
301      $sort  = apply_filters( 'get_previous_post_sort', 'ORDER BY post_date DESC LIMIT 1' );
302
303      return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join $where $sort");
304 }
305
306 function get_next_post($in_same_cat = false, $excluded_categories = '') {
307      global $post, $wpdb;
308
309      if( !is_single() || is_attachment() )