Skip to content

Instantly share code, notes, and snippets.

@marklchaves
Created March 10, 2023 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marklchaves/6d5ffeab4ce97c5ea81c6e0620a15e7e to your computer and use it in GitHub Desktop.
Save marklchaves/6d5ffeab4ce97c5ea81c6e0620a15e7e to your computer and use it in GitHub Desktop.
This template will display only the content you entered in the page editor. It'll still load header and footer scripts but not header, sidebar, and footer content.
<?php
/**
* Template Name: Landing Page Template
*
* This template will display only the content you entered in the page editor.
*
* This template is great for:
* 1) Landing pages where you don't want any distractions. You just want a sales or
* marketing funnel.
* 2) When you want to include this page in an iframe or remote content popup to avoid
* displaying duplicate content yet you need to load the header and footer scripts
* for things like forms to work.
*
* We call wp_head() to load scripts or data in the head tag on the front end.
*
* We call wp_footer() to load scripts and data before the closing body tag on
* the front end.
*
* NOTE: We don't call any getters: get_header(), get_sidebar(), and get_footer()
* because we don't want to show the top nav (menus), sidebar content, and footer content.
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Render header scripts here. -->
<?php wp_head(); ?>
<!-- Done rendering header scripts. -->
</head>
<body class="landing-page">
<?php
while ( have_posts() ) : the_post();
the_content();
endwhile;
?>
<!-- Render footer scripts here. -->
<?php wp_footer(); ?>
<!-- Done rendering footer scripts. -->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment