ctinetworks
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [Insert Pages] Issue with custom page templates.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 }
Forum: Plugins
In reply to: [Insert Pages] Issue with custom page templates.I was able to fix the problem by adding “the_post()” method within the main loop in the inserPages_handleShortcode_insert” method after while(have_posts()). The loop was not iterating thus causing it to be an infinite loop.
Viewing 2 replies - 1 through 2 (of 2 total)