WORDPRESS - Oxygen - toolset

Get WordPress title for page, post, category, archive in Oxygen

Author: Aleš Sýkora, 26. 1. 2021

Want to create only one template for Header and Footer - the main template - in Oxygen sometimes? So You need to display the title of current page, post, archive, category in one place. It cannot be done with Oxygen conditionals :(. So you have to make it done with code block and custom PHP.

<?php 
if ( is_category() ) {
 //CATEGORY
		$title = single_cat_title( '', false );
	} elseif ( is_tag() ) {
 //TAG
		$title = single_tag_title( '', false );
	} elseif ( is_author() ) {
 //AUTHOR
		$title = '<span class="vcard">' . get_the_author() . '</span>';
	} elseif ( is_post_type_archive() ) {
 //POST ARCHIVE
		$title = post_type_archive_title( '', false );
	} elseif ( is_tax() ) {
 //TAXONOMY
		$title = single_term_title( '', false );
	} elseif ( is_home() ) {
 //HOMEPAGE
		$title = single_post_title( '', false );
	}  elseif ( is_page() ) {
 //PAGE
		$title = single_post_title( '', false );
	} elseif ( is_single() ) {
 //POST
		$title = single_post_title( '', false );
	} 
?>
<h1 class="responsive-h1">" <?php echo $title; ?> "</h1>

Put it in the code block and style with .responsive-h1 class.