perarne
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Need help with complex SQL querythe least ugly way i could come up with was to make 1 and 0 mean low and high display priority respectively. this way the default sorting with
'order' => 'DESC'gives me exactly what i want. thanks for pointing me in the right direction.Forum: Themes and Templates
In reply to: Need help with complex SQL queryhmm… just realized i need to implement pagination, which will be much easier if i only do one query that actually returns exactly what i need (as opposed to using multiple queries or manipulating the order of the returned post after the query has been made).
this brings me back to my second post i guess: i need to reverse the order of the results generated by
$taxArgs = array(array('taxonomy' => 'note_category', 'terms' => 'the_category_slug', 'field' => 'slug')); $the_query = new WP_Query(array('post_type' => 'note', 'orderby' => 'meta_value date', 'meta_key' => 'display_priority', 'order' => 'ASC', 'tax_query' => $taxArgs));and i want to achieve this by manipulating the query somehow.
any ideas?
thanks
Forum: Themes and Templates
In reply to: Need help with complex SQL queryit sure does make sense. i’ll go with that solution. just wanted to see if it was possible to achieve the desired result in one query.
thanks!
Forum: Themes and Templates
In reply to: Need help with complex SQL queryi tried what you suggested but it seems that the ‘meta_query’ args affect selection as opposed to ordering, so i only get posts having a given display_priority value. or am i missing something here?
what i tried to achieve by using multiple ‘order_by’ values (as described here) in my previous post was to get a result containing posts having display_priority values of both 0 and 1, with posts having values of 1 appearing first ordered by date (descending) followed by the rest of the posts also ordered by date, hence
'orderby' => 'meta_value date'thanks again for helping me out.
Forum: Themes and Templates
In reply to: Need help with complex SQL querythanks for your quick reply and for making me read the WP_Query documentation again…
the following query gets me exactly what i want except the posts are in reverse order.
$taxArgs = array(array('taxonomy' => 'note_category', 'terms' => 'the_category_slug', 'field' => 'slug')); $the_query = new WP_Query(array('post_type' => 'note', 'orderby' => 'meta_value date', 'meta_key' => 'display_priority', 'order' => 'ASC', 'tax_query' => $taxArgs));changing ‘order’ only seems to affect the sorting by the second ‘orderby’ value.
i could probably add a hack to reverse the result, but a proper solution would be nice. any ideas?