fbpx

Create alternative page templates in Underscores theme

Create a template with no title

I look to create templates with no automatic title so that I can use a good title for SEO and manually insert my own h1 header in the body of the page.

To do this, make a copy of the file template-parts/content-page.php and call it content-no-title.php

In your new file, content-no-title.php, remove the following lines

	<header class="entry-header">
		<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
	</header><!-- .entry-header -->

Next, make a file of page.php and call it notitle.php

In your new file, notitle.php, replace the first few lines

<?php
/**
 * The template for displaying all pages
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site may use a
 * different template.
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package {theme_slug}
 */

with

<?php
/*
 * Template Name: No Title
 * @package {theme_slug}
 */

You will also need to replace

get_template_part( 'template-parts/content', 'page' );

with

get_template_part( 'template-parts/content', 'no-title' );

Leave a Reply