我正在编写一个插件,在single_template
. filter函数成功地将路径返回到myshow-post-in-a-lightbox.php
样板
正如您从其名称可以猜到的,我的模板旨在在灯箱中显示一篇文章。因此,我只需要显示帖子内容,避免显示标题栏、菜单、边栏、页脚等。然而,为了正确显示帖子内容,我需要<head>
包含所有<link>
所需样式表的标记,以及<script>
标签。
到目前为止,我的模板代码是:
<?php
/*
Template Name: show-post-in-lightbox
*
*/
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
global $post;
// Start the loop.
while ( have_posts() ) : the_post();
$content = $post->post_content;
$content = apply_filters(\'the_content\', $content);
$content = str_replace(\']]>\', \']]>\', $content);
echo $content;
它的工作原理是显示帖子内容,但它也会在上面显示标题横幅,以及站点徽标、标题(我不是说<title>
, 这个没问题,但我是说<header id="masthead" class="site-header">
), 以及所有其他的。如果我把get_header();
它只输出内容,但不输出所需的样式和脚本。
是否有只返回(或输出)<head>
标签(或仅限于</head>
标签)的标签?