我正在开发一个插件,它需要在灯箱内打开一个 wordpress 帖子。以下是一些细节:
- 目前,我正在为灯箱使用颜色箱。触发灯箱以打开一个外部 .php 文件,该文件将帖子 ID 作为 $GET 变量接收。
- 只有标题、元信息、内容和评论部分应该在灯箱中打开,而不是主题页眉和页脚。
- 所有短代码、嵌入的 youtube 链接等都应该在打开的帖子中工作。
- 如果有一种方法可以获取当前主题的 single.php 文件,从中剥离页眉、侧边栏和页脚并仅显示格式化的内容,那就太好了。但我相信这取决于主题而不是通用解决方案
这是当前的插件链接:http ://test.anshulsharma.in/
外部 php 文件的当前代码是:
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>
在当前版本的插件中,仅显示帖子内容。简码不起作用,嵌入的链接不显示。也没有办法查看或添加评论。我愿意为此编写一个自定义的 single.php 文件并添加我自己的样式。但我只想知道最好的方法,以及如何将帖子 ID(从 $GET 变量到 single.php)传送到灯箱。