Forum Replies Created

Viewing 1 Topics - 1 through 1 (of 1 total)
Author Posts
April 1, 2014 at 11:51 pm in reply to: Order of To-do Lists in Milestones 17810
Taylor Taylor

Below is a possible solution. I set the list of To-dos in Milestones to be displayed in order of the sort order configured in the To-Do Lists tab in the backend. I added the ‘orderby’ parameter to the $args array. It would be great if you committed this to the code 🙂

/**
* Get all tasks based on a milestone
*
* @param int $list_id
* @return object object array of the result set
*/
function get_tasklist_by_milestone( $milestone_id, $privacy = false ) {
$args = array(
‘post_type’ => ‘task_list’,
‘numberposts’ => -1,
‘orderby’ => ‘menu_order’,
‘order’ => ‘ASC’
);

$args[‘meta_query’][] = array(
‘key’ => ‘_milestone’,
‘value’ => $milestone_id,
‘orderby’ => ‘menu_order’,
‘order’ => ‘ASC’
);

if ( $privacy === false ) {
$args[‘meta_query’][] = array(
‘key’ => ‘_tasklist_privacy’,
‘value’ => ‘yes’,
‘compare’ => ‘!=’,
‘orderby’ => ‘menu_order’,
‘order’ => ‘ASC’
);
}

$tasklists = get_posts( $args );
foreach ($tasklists as $list) {
$this->set_list_meta( $list );
}
return $tasklists;
}

Viewing 1 Topics - 1 through 1 (of 1 total)