[wp-trac] [WordPress Trac] #3598: query_posts produces SQL error when excluding empty category

WordPress Trac wp-trac at lists.automattic.com
Tue Jan 16 22:13:08 GMT 2007


#3598: query_posts produces SQL error when excluding empty category
---------------------+------------------------------------------------------
 Reporter:  joefish  |       Owner:  anonymous  
     Type:  defect   |      Status:  new        
 Priority:  normal   |   Milestone:             
Component:  General  |     Version:  2.1        
 Severity:  normal   |    Keywords:  query-posts
---------------------+------------------------------------------------------
 When setting up the loop with query_posts, an SQL error is generated if an
 empty category is excluded. For example, if the category with the id 8 is
 empty, query_posts('cat=-8') produces:

 WordPress database error: [You have an error in your SQL syntax; check the
 manual that corresponds to your MySQL server version for the right syntax
 to use near '8 AND (post_type = 'post' AND (post_status = 'publish' OR
 post_status = 'private' at line 1]
 SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_post2cat
 ON (wp_posts.ID = wp_post2cat.post_id) WHERE 1=1 8 AND (post_type = 'post'
 AND (post_status = 'publish' OR post_status = 'private')) GROUP BY
 wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10

-- 
Ticket URL: <http://trac.wordpress.org/ticket/3598>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list