Is there a way I exclude one teacher (“Robert”) from the list in this foreach loop and put his entry separately at the top?
$teachers = get_terms('teacher');
foreach($teachers as $teacher) {
$link = get_term_link(intval($teacher->term_id),'teacher');
$description = term_description(intval($teacher->term_id),'teacher');
echo "<h3><a href=\"{$link}\">{$teacher->name}</a></h3>";
echo substr($description,0,200) . "...";
}
‘teacher’ is a WordPress taxonomy term. I am trying to create a list of all teachers with the Robert at the top as he is the head teacher.
For obvious reasons this solution is wasteful, for instance you could put the inner details into a partial to save repeating the echo code twice (Dont Repeat Yourself, DRY). It would also be better to modify the generating query so head teacher is always first result, but appreciate that may not be possible with the framework you are using.
It would also be better to use an abstracted “head teacher” value to check against, rather than hard-coding the name.