2007. 7. 14. 17:21

Embedding MG2 in WordPress

The purpose of this document is to describe the process that I used to insert my MG2 (v0.5.1) photo gallery using the default rounded skin into my WordPress (2.0.1) based web site. You can see the final result @ http://okuda.ca/gallery/.

I started with the tutorial at the MG2 support site. Unfortunately, there have been some significant changes to how WordPress themes work between 1.5 and 2.0 so that was only used as a guideline. In some cases my process was slightly easier and there were some new steps to follow....

My site is organized with the WordPress blog in /blog and the photo gallery in /gallery. What I wanted to do was keep the photo gallery as stand-alone pages, but with the look and feel of the WordPress blog. This is instead of trying to truly insert the gallery into the WordPress blog through a plugin or in a page or with an iframe. This is how the original tutorial works.

The basic process is to put the WordPress header at the top of the page and the footer at the bottom with the least amount of changes to either WordPress or MG2.

Step 1

Create two new files in the MG2 gallery “/gallery” called wpheader.php and wpfooter.php. Here are their contents.

wpheader.php


PHP:
  1. <!--p<br-->&nbsp; define(’MG2_GALLERY’, true);
  2. &nbsp; require(’./../blog/wp-blog-header.php’);
  3. &nbsp; get_header();
  4. ?>
  5. <div id="content">

     

The file above will be used to include the WordPress header into the gallery. The define('MG2_GALLERY', true); line is to allow us to identify that the header is being used by the MG2 gallery. You will see why this is important later.

출처 : http://notions.okuda.ca/mg2-hacks/embedding-mg2-in-wordpress/