How To Create A Blank Page Template In WordPress

Follow the below steps to create a new blank page template in WordPress. This would help to create pages without any extra header or body content.

Steps To Create a Blank Page Template

  1. Inside your custom theme, create a folder called “templates
  2. Create a file named “tpl-blank.php”
  3. Copy paste the below code to that file
  4. <?php /* Template Name: Blank Template */?>
    <?php
        if (have_posts()) {
            while (have_posts()): the_post();
            echo strip_tags(get_the_content(), '<p> <a>');
            endwhile;
        }
    ?>
  5. Save the file and now you would be able to create a page with “Blank Template

Blank Template

Key Points on Code Snippet

  1. The value assigned to the key “Template Name” in the first line (to be commented) would be considered as the display name of template.
  2. strip_tags function is required to remove the paragraph “<p>” tags that are rendered by default by editor of WordPress

Leave a comment