Actually my previous solution broke when using non custom page templates. Below is a better solution I came up with. I basically just set a boolean called $continue to true, add it as a condition for the while loop and then set it to false when using custom page templates. Thus ending the loop. Not sure how this solution will affect custom posts though.
$continue = true;
// Start our new Loop
while (have_posts() && $continue) {
ob_start(); // Start output buffering so we can save the output to string
// Show either the title, link, content, everything, or everything via a custom template
switch ($display) {
case "title":
the_post();
echo "<h1>"; the_title(); echo "</h1>";
break;
case "link":
the_post();
echo "<a href='"; the_permalink(); echo "'>"; echo the_title(); echo "</a>";
break;
case "content":
the_post();
echo the_content();
break;
case "all":
the_post();
echo "<h1>"; the_title(); echo "</h1>";
echo the_content();
echo the_meta();
break;
default: // display is either invalid, or contains a template file to use
$template = locate_template($display);
if (strlen($template) > 0) {
include($template); // execute the template code
}
$continue = false; // Stop the loop
break;
}
$content = ob_get_contents(); // Save off output buffer
ob_end_clean(); // End output buffering
}