get_<adjacent>_post_join

Filters the JOIN clause in the SQL for an adjacent post query.

Description

apply_filters( 'get_<adjacent>_post_join', (string) $join, (bool) $in_same_term, (array) $excluded_terms, (string) $taxonomy, (WP_Post) $post ); 

The dynamic portion(s) of the hook name refer to the type of adjacency, next or previous..

Parameters (5)

0. $join (string)
The JOIN clause in the SQL.
1. $in_same_term (bool)
Whether post should be in a same taxonomy term.
2. $excluded_terms (array)
Array of excluded term IDs.
3. $taxonomy (string)
Taxonomy. Used to identify the term used when $in_same_term is true.
4. $post (WP_Post)
WP_Post object.

Usage

To run the hook, copy the example below.
  1. $join = apply_filters( 'get_{$adjacent}_post_join', $join, $in_same_term, $excluded_terms, $taxonomy, $post ); 
  2.  
  3. if ( !empty( $join ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the get_<adjacent>_post_join callback 
  2. function filter_get_adjacent_post_join( $join, $in_same_term, $excluded_terms, $taxonomy, $post ) { 
  3. // make filter magic happen here... 
  4. return $join
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "get_{$adjacent}_post_join", 'filter_get_adjacent_post_join', 10, 5 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "get_{$adjacent}_post_join", 'filter_get_adjacent_post_join', 10, 5 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/link-template.php  
  1. $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms, $taxonomy, $post );