get_previous_post_where
Filters the WHERE clause in the SQL for an adjacent post query.
Это один из вариантов динамического хука get_(adjacent)_post_where
Использование
add_filter( 'get_previous_post_where', 'wp_kama_get_previous_post_where_filter', 10, 5 );
/**
* Function for `get_previous_post_where` filter-hook.
*
* @param string $where The `WHERE` clause in the SQL.
* @param bool $in_same_term Whether post should be in the same taxonomy term.
* @param int[]|string $excluded_terms Array of excluded term IDs. Empty string if none were provided.
* @param string $taxonomy Taxonomy. Used to identify the term used when `$in_same_term` is true.
* @param WP_Post $post WP_Post object.
*
* @return string
*/
function wp_kama_get_previous_post_where_filter( $where, $in_same_term, $excluded_terms, $taxonomy, $post ){
// filter...
return $where;
}
- $where(строка)
- The
WHEREclause in the SQL. - $in_same_term(true|false)
- Whether post should be in the same taxonomy term.
- $excluded_terms(int[]|строка)
- Array of excluded term IDs. Empty string if none were provided.
- $taxonomy(строка)
- Taxonomy. Used to identify the term used when
$in_same_termis true. - $post(WP_Post)
- WP_Post object.
Список изменений
| С версии 2.5.0 | Введена. |
| С версии 4.4.0 | Added the $taxonomy and $post parameters. |
| С версии 6.9.0 | Adds ID-based fallback for posts with identical dates in adjacent post queries. |
Где вызывается хук
get_previous_post_where
wp-includes/link-template.php 1990
$where = apply_filters( "get_{$adjacent}_post_where", $where_prepared, $in_same_term, $excluded_terms, $taxonomy, $post );