Best way to load page content in Fancybox popup?

I have found that the best way to include WordPress pages into a fancybox is to create a new template to use for those pages. For example I have some of my contact forms in a fancy box and the template I use is called custom-page-plain.php and doesn’t call header.php and contains a link to an alternate style sheet.

<?php
 /*
 Template Name: plain page
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  <meta name="MSSmartTagsPreventParsing" content="true" />
  <meta http-equiv="Imagetoolbar" content="No" />
  <title>My Form Title</title>
  <link rel="stylesheet" href="http://xxxxxxx.com/wp-content/themes/revision3/stylemin2.css?rev=676777" type="text/css" media="screen,projection" />
  <?php wp_head(); ?>
  </head>
<body>
  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  <?php the_content('read more'); ?>
  <?php endwhile; endif; ?>
  <?php wp_footer(); ?>
</body>
</html>

As you can see the template contains the the wp_head and wp_footer calls directly in the template.

Whenever I want to create a page to go in a fancybox I just choose my plain template then add the fancybox class to the link.

Leave a Comment

tech