I am developing a plugin which requires to open a single wordpress post inside of a lightbox. Here are a few details :
- Currently,I am using colorbox for lightbox. The lightbox is triggered to open an external .php file which received the post id as $GET variable.
- Only the Title, Meta information, Content and comments part should open in the lightbox and not the theme header and footers.
- All the shortcodes , embedded youtube links etc should work in the opened post.
- It would be great if there is a way to pick up the current theme's single.php file, strip the header , sidebar and footer from it and display only the formatted content. But i believe that depends on themes and is not a generic solution
Here is the current plugin link :http://test.anshulsharma.in/
The current code for the external php file is :
if(!function_exists('get_post'))
{
require_once("../../../../wp-load.php");
}
$thepost = get_post($_GET["ID"]);
$thecontent = $thepost->post_content;
$thetitle = $thepost->post_title;
$thelink = get_permalink($_GET["ID"]);
?>
<div id="cg-post-container" style="width:<?php echo get_cg_option('lightbox_width'); ?>px;">
<div id="cg-post-title">
<a href="<?php echo $thelink; ?>"><?php echo $thetitle; ?></a>
</div>
<div id="cg-post-content">
<?php echo $thecontent; ?>
</div>
</div>
In the current version of the plugin, only the posts content shows up. Shortcodes dont work and embeded links dont show up. Also there is no way to view or add comments. I am willing to write a custom single.php file for this and add my own styling . But i just want to know the BEST way to do it and also how to communicate the post id (from the $GET variable to the single.php) to the lightbox.
<?php echo $thecontent; ?>
with<?php echo apply_filters('the_content', $thecontent); ?>
– Jen Nov 16 '12 at 15:05