I have some custom blocks (m-txt, m-img, m-gallery). Each of the blocks has their own field title
.
When I render an HTML code for all blocks I pus title into <h2></h2>
tags.
I would like to choose the first block on the page and replace <h2>$title</h2>
it with <h1><?php echo get_post_title()?></h1>
(post title override custom title) tags.How can I detect that this is a first block and make any changes on it?
Example module render code:
<?php
$title = get_field('title');
$html = '';
if(!empty($title)){
$html .= '<section class="block">';
$html .= '<div class="container module__container">';
$html .= '<div class="module__header">';
$html .= '<h2>' . $title . '</h2>';
$html .= '</div>';
$html .= '</div>';
$html .= '</section>';
}
echo $html;