I'm coding a plugin that adds a filter to
single_template. The filter function successfully returns the path to my
As you can guess from its name, my template is intended to show a single post in a lightbox. Therefore I need to show only the post content and avoid the title bar, menus, sidebars, footers and so on. However, for the post content to show correctly, I need the usual
<head> section with all the
<link> tags to the required stylesheets and
My template code so far is:
<?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;
This works in that it shows the post content, but it also shows the heading banner above it, with the site logo, the title (I'm not talking about
<title>, that one is ok, but I mean
<header id="masthead" class="site-header">), and all the rest therein.
If I comment out the
get_header(); line it outputs only the content, but without the required styles and scripts.
Is there a function that returns (or outputs) only the
<head> tag (or only up to the
</head> tag) of a given post?