Opened 12 months ago
Last modified 2 months ago
#43056 new defect (bug)
Notice in redirect_guess_404_permalink() when post type is an array
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 5.1 | Priority: | normal |
| Severity: | normal | Version: | trunk |
| Component: | Canonical | Keywords: | has-patch |
| Focuses: | Cc: |
Description
When manipulating URLs, it sometimes becomes necessary to update the query using the pre_get_posts hook.
If we set the post type to an array in the pre_get_posts hook like so:
$query->set( 'post_type', array( 'post', 'page', 'my_cpt' ) );
On a 404 page, we get a notice when WP_DEBUG is set to true:
Notice: wpdb::prepare was called incorrectly. The query only expected one placeholder, but an array of multiple placeholders was sent.
This is caused by the following code in redirect_guess_404_permalink():
$where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type'));
This can be fixed by looking for an array and updating the query.
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.