// link artist name with first work by that artist
$term_list .= '<li><a href="' . get_term_link( $term->slug, $term->taxonomy ) . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">' . $termfirst . ' ' . $term->name . '</a></li><li>' . the_terms() . '</li>';
change the above lines to
$posts = get_posts(array(
'post_type' => 'artworks',
'numberposts' => 1,
'post_status' => 'publish',
'artists' => $term->slug,
'orderby' => 'date',
'order' => 'DESC'
));
// link artist name with first work by that artist
$term_list .= '<li><a href="' . get_permalink( $posts[0]->ID ) . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">' . $termfirst . ' ' . $term->name . '</a></li><li>' . the_terms() . '</li>';
This will change the link to the latest post. You will probably want to modify the “orderby” & “order” parameters in the code. The possible values are available here http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
In your code you don’t need the line $first_cat_post = get_posts($args);
Also please correct the parameters in the $args
, see this page for reference http://codex.wordpress.org/Function_Reference/get_terms