WP query sort order
-
hi guys,
i’m trying to sort my posts in a custom post order.
$partner = new WP_Query( array( 'post_type' => 'partner', 'posts_per_page' => -1, 'nopaging' => true, 'meta_query' => array($meta_query) ) );
starts my query. all fine.
i’m trying to sort my posts in a cusstom sort order.
this works:
global $query_string; query_posts( $query_string . '&order=ASC' );
this doesn’t:
global $query_string; query_posts( $query_string . '&order=ASC&orderby=name' );
why?
i also tried
$args = array_merge( $partner->query_vars, array( 'order' => 'DESC','orderby' => 'name' ) ); query_posts( $args )
no effect either. args are merged correctly, but sort order doesn’t change.
2nd question:
i execute a second query that checks inside custom post type projects which projects th partner took place in:
function solarhaus_verlinkung($partner_name){ $meta_query[]=array( 'relation' => 'OR', array('key' => 'planung_gebaeude','value' => $titel_clean,'compare' => 'LIKE'), ); $solarhaeuser = new WP_Query( array( 'post_type' => 'solarhaus', 'posts_per_page' => -1, 'meta_query' => array($meta_query) ) ); $solarhaeuser->wp_reset_postdata(); return $solarhaeuser; }
this gives me the number of the partners projects.
what would be the best way to first sort by date ASC then by number of projects? could i set up something likewhile ( $partner->have_posts() ) : $partner->get_the_post()['projects_number'] = "xo";
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘WP query sort order’ is closed to new replies.