mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-09-22 00:40:20 +00:00
Canonical: Support multiple post types in redirect_guess_404_permalink().
Prevent `redirect_guess_404_permalink()` from throwing a notice when multiple post types are included in the `post_type` query. Props junaidbhura. Fixes #43056. git-svn-id: https://develop.svn.wordpress.org/trunk@49200 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -895,7 +895,12 @@ function redirect_guess_404_permalink() {
|
||||
|
||||
// If any of post_type, year, monthnum, or day are set, use them to refine the query.
|
||||
if ( get_query_var( 'post_type' ) ) {
|
||||
$where .= $wpdb->prepare( ' AND post_type = %s', get_query_var( 'post_type' ) );
|
||||
if ( is_array( get_query_var( 'post_type' ) ) ) {
|
||||
// phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
|
||||
$where .= " AND post_type IN ('" . join( "', '", esc_sql( get_query_var( 'post_type' ) ) ) . "')";
|
||||
} else {
|
||||
$where .= $wpdb->prepare( ' AND post_type = %s', get_query_var( 'post_type' ) );
|
||||
}
|
||||
} else {
|
||||
$where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user