I thought it worth making a note here: I was having trouble where a category wasn’t properly excluded when doing a query such as
$custom_query = new WP_Query('cat=-5')against SQL Server 2005. I tracked the problem down to the way LIMIT is changed into TOP in translations.php. The limit was being applied to the sub-query in the NOT IN statement as well as the main query. A simple change on line 707 of translations.php fixed the problem.
$query = str_ireplace('DELETE ', 'DELETE TOP ' . $limit_matches . ' ', $query); $query = str_ireplace('SELECT ', 'SELECT TOP ' . $limit_matches . ' ', $query);
$command_pos = stripos($query, 'DELETE '); if (command_pos === false) $command_pos = stripos($query, 'SELECT '); if (command_pos !== false) $query = substr_replace($query, 'TOP ' . $limit_matches . ' ', $command_pos + 7, 0);
- The topic ‘LIMIT fix for excluding categories’ is closed to new replies.