clickable title of 2 post on mainpage USING functions.php

here is answer 🙂

add_action('generate_after_header', 'work_only_on_front_page', 999);
   function work_only_on_front_page(){
    if ( is_front_page() ) {
        
 echo '
 
 any text with divs';

  
        
           $args = array(
       'posts_per_page' => 2, // we need only the latest post, so get that post only
       'cat' => '1' // Use the category id, can also replace with category_name which uses category slug
    );
        
    $recent_posts = wp_get_recent_posts( $args );
    foreach( $recent_posts as $recent ) {
        printf( '<a href="%1$s" class="dwanaglownej">%2$s<br /><i>czytaj ></i></a>',
            esc_url( get_permalink( $recent['ID'] ) ),
            apply_filters( 'the_title', $recent['post_title'], $recent['ID'] )
        );
    }
        
 
               
 
  echo '
 
 any text with divs
';
   }
}