Category Archives generating wrong DB query and ignoring orderby commands
-
I have an installation of wordpress 3.1.1 and this has been happening since v. 3.1 at least.
on category archive pages, wordpress generates incorrect database queries, specifically ignoring orderby types of commands.
it happens even on very simple category.php template files:
[Code moderated as per the Forum Rules. Please use the pastebin]
Yes, there are a number of print_r statements in there for debugging.
It generates the following in $wp_query:
[request] => SELECT wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (25,70,71,72,73) ) AND wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘private’) GROUP BY wp_posts.IDthe array that becomes the query string is :
Array
(
[category_name] => base-category/child-category (these are renamed but this is the structure)
[meta_key] => post-order
[orderby] => meta_value_num
[order] => ASC
)I have tested passing both ASC and DESC into the query string. No change. It also ignores order by.
- The topic ‘Category Archives generating wrong DB query and ignoring orderby commands’ is closed to new replies.