PHP Notice: Undefined offset: -1 – Navigation Previous/Next

It depends on number of things

  • how you want to design, if this is the first post, does it still have previous class? Some design create loops, first post previous will go to the last post like a loop, some design does not display the previous button if it is the first one.
  • the design will then determine how you will code and create the logic for frontend

For instance, I guess your first $pos return 0;

$pos = array_search( $post_id, $exhibs );

 if( $previous ) {
  $new_pos = $pos - 1; // if first $pos is 0, the $new_pos is -1
  $class="nav-previous";
 } else {
  $new_pos = $pos + 1;
  $class="nav-next";
 }
 if( $exhibs[$new_pos] ) { // $exhibs[-1] does not exist, so undefined error occur

 }

Possible correction for avoiding error (it really depends on how you want to design)

if( $new_pos > 0 && $exhibs[$new_pos] ) {} 

// or 

if( isset( exhibs[$new_pos] ) {}