Question

I would like to have some links which load the page content of the page they reference to inside a Fancybox popup(pages like "shipping" or "returns", mainly text content).

I would create the pages an then I will add the permalinks to these pages to other sections, like footer or sidebar, and they will open in the popup window.

Have you come across anything like that? What would be the best way to implement it??

Any suggestion will be greatly appreciated.

Was it helpful?

Solution

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.

OTHER TIPS

Well best option in my opinion is hardcoding the contents of the boxes and just putting the divs in the footer. Hassle if you've got a client wanting to edit via WordPress. Next option is to get the page contents for each of these in the footer for each div. Kinda wasteful. Next option, most likely what you're looking for is adding an action into wp_loaded and handling the request there by hand and then kill the process.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top