Archived topic
Where to set the h1, h2 (...) tags? They are not set by defaulton the .php files
3 replies · Started by Patricia on September 5, 2018
Hi,
Where can I set the h1, h2, h3? I saw there's not defined the h titles in the .php files:
home.php (that php file doesn't even exist, i don't know were to define the h1 for the homepage)
page.php
search.php
single.php
comments.php
I want to set the h1 as the title of the blog in the main site, but h1 should be the title of each post, for example.
thanks!
Hi there,
h1 elements are used for all single pages and posts by default.
h1 elements shouldn't be used on the blog page, as there should only be one h1 per page.
If you need to switch it to h1, you'd need to copy the content.php file from the parent theme, and add it to your child theme.
Then you can change the element on this line: https://github.com/tomusborne/generatepress/blob/2.1.4/content.php#L34
hi!:
thanks. I saw the current h1 and h2 are correct, but the "Coments.php" file has the title "Comments" in h3 and i want to change it to h2.
I have to create a child file (or child theme??) for the comments.php and change the h3 for the h2, there? Can you show me how to make a child file or a child theme??
if ( have_comments() ) : ?>
<h3 class="comments-title">
<?php
$comments_number = get_comments_number();
if ( 1 === $comments_number ) {
printf(
/* translators: %s: post title */
esc_html_x( 'One thought on “%s”', 'comments title', 'generatepress' ),
'<span>' . get_the_title() . '</span>'
);
} else {
printf( // WPCS: XSS OK.
/* translators: 1: number of comments, 2: post title */
esc_html( _nx(
'%1$s thought on “%2$s”',
'%1$s thoughts on “%2$s”',
$comments_number,
'comments title',
'generatepress'
) ),
number_format_i18n( $comments_number ),
'<span>' . get_the_title() . '</span>'
);
}
?>
</h3>
Hi there,
First, install and activate a child theme: https://docs.generatepress.com/article/using-child-theme/
Then copy the comments.php file from the parent theme, and add it to your child theme.
Once you do that, you can open the child theme comments.php file, and make your changes.
Let me know if this helps or not :)