[wp-trac] [WordPress Trac] #16949: Custom post types: error on page if query contains multiple post types
WordPress Trac
wp-trac at lists.automattic.com
Wed Jun 22 19:07:16 UTC 2011
#16949: Custom post types: error on page if query contains multiple post types
--------------------------+------------------
Reporter: mastermind | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.2
Component: General | Version: 3.1
Severity: normal | Resolution:
Keywords: |
--------------------------+------------------
Comment (by aaroncampbell):
The problem turned out to be that `wp_old_slug_redirect()` expects
post_type to be a string. It not only passes it straight to
`is_post_type_hierarchical()` but a couple lines later it pushes into a
query using `$wpdb->prepare()`. This leaves two options: Upgrade
`wp_old_slug_redirect()` to handle multiple post types, or bail when we
see we have multiple post types.
As nacin pointed out in chat " One might argue that you can't guess which
page to redirect to if it could be one of a few post types". It seems to
me that our guess would be less accurate, but we still might be able to do
it. Both options have their advantages.
Not guessing would open things up for whoever is adding the additional
post types to the query to do the guessing themselves. A little less
"magical" but pretty flexible. This is attached as
[attachment:16949.diff]
If we want more magic we could actually force post_type to an array, loop
through and generate the post_type= bits of the query from the non-
heirarchical post_types, which creates a query like this:
{{{
SELECT post_id FROM wp_postmeta, wp_posts WHERE ID = post_id AND (
post_type = 'somepostype' OR post_type = 'anotherposttype' ) AND meta_key
= '_wp_old_slug' AND meta_value = 'bad-slug'
}}}
This is attached as [attachment:16949.2.diff]
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16949#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list