Friday , December 20 2024

How to display h1 in WordPress theme

This task is relevant for cases when developers in custom templates for some reason decide not to display the page title, although according to all SEO requirements it should be, and should be wrapped in h1.

Heading Examples

1. In the page template:

in the page.php of your theme, add the following construction:

<?php echo '<h1>'. esc_html( get_the_title() ) .'</h1>'; ?>

2. In the post template:

in the file single.php or content-single.php add the same code:

<?php echo '<h1>'. esc_html( get_the_title() ) .'</h1>'; ?>

3. In the categories template (post archives):

in the file archive.php add this code:

<?php the_archive_title( '<h1 class="page-title">', '</h1>' ); ?>

About admin

Hi there! My name is Iryna, I am a web developer from Ukraine. While working on freelance projects I often face different technical issues and in this blog I publish articles on how to solve them. I am also interested in digital drawing and in this blog you will find brief tutorials that helped me and hopefully can help you as well.

Check Also

How to remove 404 //fonts.gstatic.com and //fonts.googleapis.com from WordPress head section

I tried solutions with functions that should remove from head and , but a very …

Leave a Reply

Your email address will not be published. Required fields are marked *