[wp-trac] [WordPress Trac] #45868: Creating a custom post type with the name of "order" breaks sorting
WordPress Trac
noreply at wordpress.org
Tue Jan 8 21:02:12 UTC 2019
#45868: Creating a custom post type with the name of "order" breaks sorting
---------------------------+-----------------------------
Reporter: calvintennant | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
Using the specific custom post type name "order" causes incorrect sql to
be generated in WP_Query and in WP_List_Table. It is easily reproduced by
creating a custom post type named "order" and trying to sort list of posts
in the wordpress admin. It should be noted that the sorting functionality
breaks for all content types after adding the "order" content type, it is
not isolated to the new type but even the default "posts" type will no
longer sort.
When sorting the table (after clicking "title" in the wordpress admin) a
query like the one below is generated:
{{{#!php
<?php
SELECT posts.* FROM posts WHERE 1=1 AND posts.post_name = 'asc' AND
posts.post_type = 'order' ORDER BY posts.post_title
}}}
Look specifically at the "WHERE"
{{{#!php
<?php
AND posts.post_name = 'asc'
}}}
I was able to work around this bug by changing the name of my custom post
type from "order" to something else.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45868>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list