Slow page Loads When Using Dynamic Coding

I’m not sure, if it is the root of the problem, but the thing that I noticed is that your code ends up calling get_post_meta quite many times (64? 8 loops within 8 loops, yes?) for the same post.

Perhaps you could get all of the post meta just once, before the for loop. Then within your loop use isset() or ! empty() to check if the data exists.

Something along these lines,

$post_meta = get_post_meta($post->ID); // This returns an array with all the data in position 0, if I remember correctly
for ($i = 0; $i < 8; $i++) {
  for ($j = 0; $j < 8; $j++) {
    if ( isset( $post_meta[0]['_tag_to_use_'.$i.'_'.$j] ) ) {
      $tag_to_use = $post_meta[0]['_tag_to_use_'.$i.'_'.$j];
      // The meta value might be in a array with the position 0, var_dump $tag_to_use to see if this is the case
      // $tag_to_use = $post_meta[0]['_tag_to_use_'.$i.'_'.$j][0];
      $tag_string = $tag_to_use ? $tag_string .= $tag_to_use . ',' : $tag_string .= '';
    }
  }
}

Use var_dump to check that you get the array indexes correct and maybe_unserialize() the meta data, if needed.

I don’t know if this is just broscience and wishful thinking, but maybe it’s worth the try. You can of course use microtime to get a rough idea, if the loop above is faster than the original.