WordPress archives by custom field and date

This will get the posts filtered by custom field and its value based on categories.

$args = array( ‘post_type’=>’post’,

            'category__in'=> array(6, 7, 31), //category id

            'meta_key'=>'keys', // customfield name
                'meta_value'=>5, // customfield value
                    'posts_per_page'=>-1,
                        'number_posts'=>-1 );

$s = get_posts($args);

foreach($s as $e ) {

echo $e->ID.'<br/>';

echo $e->post_title.'<br/>';

}