Pull custom fields from custom posts within a loop

I’ll presume you are using something like this…to get the custom value you want. Once you are inside the loop.

$customfieldvalue = get_post_meta($post->ID, "metakeyname", true);

Since you are using $model as the base for a query. You could create a function That will query what you want, and then reset the current query. You could use it wherever you want. Here is a template.

function modelquery($model) {
    global $wp_query, $post, $paged, $post_count;

        // YOUR QUERY
        $query_args = array (
            'numberposts' => 5, 
            'post_type' => 'documents', 
            'category_name' => $model
        );    

        // SAVE CURRENT QUERY
        $temp = $wp_query;
        $wp_query= null;    

        // CREATE NEW QUERY
        $wp_query = new WP_Query();
        $wp_query->query($query_args);      

        // THE LOOP, DO WHAT YOU HAVE TO DO HERE
        while ($wp_query->have_posts()) : $wp_query->the_post();    
            $customfieldvalue = get_post_meta($post->ID, "metakeyname", true);
            echo $customfieldvalue;
        endwhile;   

        // SWAP BACK THE PREVIOUS QUERY
        $wp_query = null; 
        $wp_query = $temp;
        wp_reset_query();       


}