Title within H1 element

I try to set automatic titles within H1 element.

How to manage using WordPress theme using one generic variable for all pages to detect Titles.
An example:

if ( is_page('about Us') ) {echo('About Us Title');}

else if( is_front_page() || is_home() ) {echo('Home page');}

I have tested If sentences:

if ( is_front_page() && is_home() ) {// Default homepage ( both the front page and the recent posts page)
echo('Default homepage');

} elseif ( is_front_page() ) {// Static homepage
echo('Static homepage');

} elseif ( is_home() ) {// Blog page
echo('Blog page');

} else {




Is there an issue with the above code as Title element is not showing?

Don’t you need to echo the wp_title?

Yes, but it does not work when I try.

Thank you for the message!
I have tested and added the following code:

//$title = wp_get_document_title();
$title = wp_title( '|', false, 'right' );
echo $title;

It seems it is showing Title:Contact Us my Test – Example.com
How to get rid of – Example.com and just show up pure Title? Contact Us my Test
As I understand $title = wp_title( ‘|’, false, ‘right’ ); will show only TITLE?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.